Best Way to Invoke Any Cross-Threaded Code?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I know that this question has been asked before, but I'm looking for a way to: streamline the creation of safe cross-threaded code. reuse this code in any situation (no Windows Forms references). Here's what I have so far, but I want to remove the Windows Forms references. Any ideas? public delegate void SafeInvokeDelegate(System.Action action); public class SafeInvoke { private readonly System.Windows.Forms.Control _threadControl; public SafeInvoke() { _threadControl = new System.Windows.Forms.Control(); } public void Invoke(System.Action