-2
我试图实现WPF示例后的一个方面,但我无法弄清楚如何使它适用于WinForms。如何将'在UI上运行'从WPF转换为Windows窗体?
class RunOnUIThreadAttribute : IMethodInterceptionAspect
{
public override void OnInvoke(MethodInterceptionArgs args)
{
DispatcherObject dispatchedObj = (DispatcherObject)args.Instance;
if (dispatchedObj.CheckAccess())
{
args.Proceed();
}
else
{
dispatchedObj.Dispatcher.Invoke((Action)(() => args.Proceed()));
}
}
}
如何获得在Windows窗体上工作的Dispatcher
的等效项?
你知道如何切换到UI线程Windows窗体中一个方面的外? – nvoigt
有用的SO链接:http://stackoverflow.com/questions/4928195/c-sharp-windows-forms-application-updating-gui-from-another-thread-and-class和http://stackoverflow.com/questions/661561/how-to-update-the-gui-from-another-thread-in- – seveves