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

发布于 2025-01-02 18:53:28 字数 1375 浏览 1 评论 0原文

请您建议如何

org.eclipse.swt.ole.win32.OleFrame

在非 UI 线程中使用? 创建“OleFrame”,如果在非 UI 线程中完成,则会抛出异常。 我确实知道 UI 线程和非 UI 线程之间的区别。 我想要实现的是在每次 OLE 调用后在“IRunnableWithProgress

添加

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

”中使用 org.eclipse.swt.ole.win32.OleAutomation 添加(在构造函数中给出 mShell)有一点帮助,但还不够……

任何帮助将不胜感激。

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");
        ...
    }   
}

Would you please advice how to use

org.eclipse.swt.ole.win32.OleFrame

in non UI thread?
Creating an "OleFrame", if done in non UI thread throws.
I do know the difference between UI and non-UI thread.
What I am trying to achieve is to use org.eclipse.swt.ole.win32.OleAutomation in `IRunnableWithProgress

Adding

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

(mShell is given in the constructor) after each OLE call helps a bit but not enough ...

Any help will be appreciated.

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");
        ...
    }   
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文