
12-02-2008, 9:55 AM
|
 |
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
|
|
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,318
Reputation: 1315
|
|
You can use the FormClosing event and e.Cancel it depending on e.CloseReason and your own thread work reason.
Note that the application user is in command, so if user want to close it regardless of what goes on she should be allowed to do so without needing to kill the process. What you can do is to check if work is in progress and if user tries to close you present a dialog that tell user what is going on and give option to continue/close, if user chooses to close anyway you should stop that thread work right away and allow the dialog form to close. You can also do this without "another dialog from the dialog" by making it clear what is happening with for example a statusstrip with status text and progress, which makes it obvious to user if cancelled before 100% whatever is going on will not complete.
|