如何开始在C#中的UI线程线程、UI

2023-09-03 00:12:15 作者:∝╬══→爱情是不う可等

我知道我可以使用.NET启动一个新的工作线程。但我怎么启动一个新的UI线程(像MFC)?

I know I can start a new worker thread from with .NET. But how do I start a new UI thread (like in MFC)?

我不介意的解决方案仅限于Windows机器;我也想解决是纯粹的.NET - 无P /调用到的CreateThread等

I don't mind if the solution is restricted to Windows boxes only; I also would like the solution to be purely .NET - no p/invokes to CreateThread, etc.

任何输入AP preciated。

Any input appreciated.

推荐答案

使用Application.Run - 它开始在当前线程的消息循环。有重载采取的形式入手,或应用程序环境,或者两者都不是。 (如果你想这样做了的新的主题,你需要创建线程,并以正常的方式启动,并使其拨打 Application.Run

Use Application.Run - it starts a message loop in the current thread. There are overloads to take a form to start with, or an application context, or neither. (If you want to do this for a new thread, you need to create the thread and start it in the normal way, and make it call Application.Run.)