更新时间:2022-04-28 03:26:53
如果我理解你的问题,你想在运行任务时退出应用程序。
如果这是例如,你必须将任务与运行用户界面的线程分开。
一个简单的方法是利用 BackgroundWorker [ ^ ]。这样,您可以单独运行任务,并且仍然可以在UI中注册按钮按下。当按下取消按钮时,只需停止背景工作者并退出应用程序。
If I understood your question correctly, you want to exit the application when it's running a task.
If this is the case, you have to separate the task from the thread running the user interface.
One easy way is to utilize BackgroundWorker[^]. With that, you can run the task separately and still be able to register button press in the UI. When a cancel button is pressed, simply stop the backrground worker and exit the app.
Application.Exit();
试试这个
try this
对于Softwate退出:
Ex 1:
Application.Exit();
例2:
Environment.Exit(Environment.ExitCode);
Thx:)
For Exit on Softwate :
Ex 1 :
Application.Exit();
Ex 2 :
Environment.Exit(Environment.ExitCode);
Thx :)