RE: backgroundworker thread
- From: jetan@xxxxxxxxxxxxxxxxxxxx ("Jeffrey Tan[MSFT]")
- Date: Thu, 22 Feb 2007 06:36:00 GMT
Hi Chuck,
Sorry for the late response, I am out of office yesterday.
Oh, yes, if your requirement is how to prevent the application from closing
before the background task is done, you may stop the main form from closing
in FormClosing event. The thread you found use a ManualResetEvent to do the
interthread synchronization.
Another choice is setting FormClosingEventArgs.Cancel to true in
Form1_FormClosing event(which cancels the form closing), then you may pop
up a dialog to the end user to notify them the background task is still in
process. This choice may be better than the ManualResetEvent one because
ManualResetEvent.WaitOne() calling in FormClosing event will hang the UI
thread of your winform application, which makes the use confused. If the
background task will cost long time, the hang may make the users think
there is something wrong in the application, so they may use task manager
to kill the winform application.
Anyway, if you have anything unclear, please feel free to tell me, thanks.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
.
- References:
- RE: backgroundworker thread
- From: "Jeffrey Tan[MSFT]"
- RE: backgroundworker thread
- From: Chuck P
- RE: backgroundworker thread
- Prev by Date: How to add pinned panels / user controls to the form
- Next by Date: RE: How to set tab order correct in a C# userControl hosted in an
- Previous by thread: RE: backgroundworker thread
- Next by thread: RE: backgroundworker thread
- Index(es):
Relevant Pages
|