-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