Calling windows form method from class file
I want to force closing a windows application by calling application.exit()
on the class file开发者_如何转开发. But it only hide the application, the .exe still running on the task manager.
I want to ask is there a way to fully terminate the windows application that can call on the class file? I can't call the windows form method from class file to perform this.close()
.
Application.Exit
only closes the Winforms event loops, i.e. only the so called GUI thread is terminated.
You could call the Environment.Exit
method to terminate the whole process. But if you have other threads running you should take care to terminate them properly, usually by sending them some message (but this depends entirely on your architecture).
精彩评论