如何在java中的非UI线程中使用OleFrame?

时间:2012-02-06 17:52:49

标签: java swt ui-thread

请您建议如何使用

org.eclipse.swt.ole.win32.OleFrame

在非UI线程中? 创建“OleFrame”,如果在非UI线程抛出中完成。 我知道UI和非UI线程之间的区别。 我想要实现的是在`IRunnableWithProgress

中使用org.eclipse.swt.ole.win32.OleAutomation

添加

for(;mShell.getDisplay().readAndDispatch(););

(在构造函数中给出mShell)每个OLE调用有点但但不够......

任何帮助将不胜感激。

OutlookHelper outlook = new OutlookHelper(mShell, mModel.getEmailToAddresses(), "Feedback report", emailInfo.body, attachment);
new ProgressMonitorDialog(mShell).run(true, false, outlook);

public class OutlookHelper implements IRunnableWithProgress {
    public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
        monitor.beginTask("Sending...", IProgressMonitor.UNKNOWN);
        send(monitor);      
        monitor.done();
    }

    private void send(IProgressMonitor monitor) throws InterruptedException {

        monitor.subTask("Creating OLE frame");
        // Will block UI thread here ...
        final OleFrame frame = new OleFrame(mShell, SWT.NONE);

        monitor.subTask("Starting Outlook application");
        // Will block UI thread here ...
        OleClientSite site = new OleClientSite(frame, SWT.NONE, "Outlook.Application");
        ...
    }   
}

0 个答案:

没有答案