Reputation: 2407
My problem is that the application doesn't terminate when I close the form using the close box on the caption bar.
When I am in the middle of some I/O operation i want to quit the application without performing the I/O operation.
Actually it seems as if the program is closed but task manager's process list shows that it is not.
How i can cancel I/O operation by force?
Upvotes: 0
Views: 179
Reputation: 140
I recommend you the following:
The first point used along with one of the others (2 or 3) should be enough. good luck!
Upvotes: 2
Reputation: 13248
If you have any infinite loop running in your app make your thread run in background threads before you start them then they will be closed automatically when the application exits.
Try to do it this way:
Thread somethread = new Thread(...);
someThread.IsBackground = true;
someThread.Start(...);
Upvotes: 1
Reputation: 48522
How are you attempting to close your application?
Application.Exit just asks to be closed down via a message loop. It might not happen.
The best way is to close any non-background threads you might have executing. Not doing so will keep your process running.
You can also try Environment.Exit or Environment.FailFast. This is like killing your process.
Upvotes: 1
Reputation: 38684
Closing form only makes the form invisible. However if there is any process running in the main or other thread, the app would not terminated. You have to make sure all the resources are closed or disposed.
Upvotes: 1