使用dispatcher.BeginInvoke时,何时/为什么需要调用Dispatcher.Run?
|
另外,如果我将this.dispatcher与另一个BeginInvoke重用,是否还需要\“ Dispatcher.Run \”?
var thread = new Thread(() =>
{
this.dispatcher = Dispatcher.CurrentDispatcher;
this.dispatcher .BeginInvoke(new Action(() =>
{
try
{
do something
}
catch (Exception ex)
{
onNotify(ex);
}
}));
Dispatcher.Run();
});
thread.Name = string.Format(\"{0} Hook Thread\", this.GetType().Name);
thread.IsBackground = true;
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
没有找到相关结果
已邀请:
1 个回复
郸身
将代表添加到调度程序的事件队列中。 仅在
内部处理队列。
是一个阻止调用,它将永久执行(或直到您致电
)。 如果再次调用
,
将立即看到新的委托并立即执行。 (或尽快免费)