Excel COM AddIn:在状态栏中显示消息 - 多线程问题 [英] Excel COM AddIn: display message in status bar - multi thread issue
问题描述
不是VSTO,excel 2007
单击功能区按钮时,会弹出非模态UI窗口,用户可以单击窗口上的按钮来运行作业(后台工作者),通常工作需要很长时间。因此,用户关闭UI窗口并执行其他操作。计时器在后台
worker中启动。 每隔5秒,计时器将轮询以查看作业是否完成。如果完成,我将在Excel的状态栏中显示一条消息,通知用户,作业失败或成功。
  ; public void SetStatus(字符串状态)
{
试试
{
lock(statusBarLock)
{                   
                    ExcelApp.StatusBar = status;
}
}
catch(InvalidOperationException)
$
{
}
}
我关心的是状态栏属于UI线程,但我在timer_tick线程中修改它可能会导致问题。我测试并没有发现问题
只是想看看这是否有任何问题,wha是正确/更好的方法来实现这个目标吗?
谢谢
孩子们祝福
< blockquote>
任何建议或评论?
请询问我的问题是否不清楚
Not VSTO, excel 2007
when a Ribbon button is clicked, a non-modal UI window pops up, users can click buttons on the window to run a job (background worker), usually the job takes long. So users close out the UI window and do something else. A timer is started in the background worker. Every 5 sec, the timer will poll to see if the job is done. If it is done is done, I will display a message in status bar of Excel to inform users, job fails or succeeds.
public void SetStatus(string status)
{
try
{
lock (statusBarLock)
{
ExcelApp.StatusBar = status;
}
}
catch (InvalidOperationException)
{
}
}
My concern is status bar belongs to UI thread, but I modify it in timer_tick thread which may cause problem. I test and did not catch the issue
Just want to see if there is any problem with this, wha is the right/better way to accomplish this?
thanks
Kids are blessing
Any advice or comment?
Pls ask if my question is not clear
这篇关于Excel COM AddIn:在状态栏中显示消息 - 多线程问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!