如何在java中的非UI线程中使用OleFrame?
请您建议如何
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论