使用回调调用UI线程 [英] Invoking the UI thread with a callback
本文介绍了使用回调调用UI线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问题1
使用行动,行动< T>等我可以使用BeginInvoke并指定回调:
Using Action, Action<T> etc I can use BeginInvoke and specify a callback:
Action<Transfer> Action = new Action<Transfer>(RoutineUnderNewThread);
ReturnedObject returnedObject = new ReturnedObject();
Transfer transfer = new Transfer();
Action.BeginInvoke(transfer, CallBack, returnedObject);
推荐答案
MyForm.Invoke(MyDelegate)将阻止当前线程,直到MyDelegate完成。我假设您在CallBack方法中调用了MyForm.Invoke(MyDelegate)。因此,您可以在MyForm.Invoke(MyDelegate)之后放置任何代码,一旦MyForm.Invoke(MyDelegate)
完成,它将启动
MyForm.Invoke(MyDelegate) will block the current thread until MyDelegate finishes. I assume you are calling MyForm.Invoke(MyDelegate) in your CallBack method. So you can put any code after MyForm.Invoke(MyDelegate) and it will kick in once MyForm.Invoke(MyDelegate) finished
这篇关于使用回调调用UI线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文