运行环境:Eclipse 3.0.x
下面是的方法实现了一个简单的“进度条对话框”:
private byte[] progressMonitorDialogTest(final String bhContent, final String root, final String userName, final String pwd, final String payload) throws Exception {
final byte[][] result = new byte[1][];
IRunnableWithProgress pro = new IRunnableWithProgress () {
//实现接口中的execute方法:
protected void execute(IProgressMonitor monitor) throws CoreException {
//具体的业务逻辑:
result[0] = invokeDLL(bhContent, root, userName, pwd, payload);
}
//实现接口中的run方法,该方法是一个同步方法:
public synchronized final void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
try {
//总的工作量
int totalWork = IProgressMonitor.UNKNOWN;
monitor.beginTask("A Progress monitor dialog exampl