R
Robert Speck
Hi there,
Can anyone shed anymore light on why "Thread.Suspend()" has been deprecated
by MSFT beyond what MSDN says about it. I'm not sure if I quite appreciate
the various pitfalls they discuss but using it under certain circumstances
still seems reasonable. For instance, I want to display a small modal dialog
with a "Cancel" button which allows the user to abort a background thread.
If the user clicks this button, I then want to prompt them to confirm the
cancellation. While the confirmation dialog is on-screen however, I want to
suspend the background thread until the user makes their decision. Is this
considered a dangerous approach however. The only other alternative I can
think of is to have my background thread periodically inspect some event
object (say, "AutoResetEvent") which the main GUI thread can [re]set as
required (the background thread will then start and stop accordingly). This
is an unwieldy approach IMO however and it also allows the background thread
to briefly continue its work until it gets around to checking the event. Any
comments would be appreciated. Thanks.
Can anyone shed anymore light on why "Thread.Suspend()" has been deprecated
by MSFT beyond what MSDN says about it. I'm not sure if I quite appreciate
the various pitfalls they discuss but using it under certain circumstances
still seems reasonable. For instance, I want to display a small modal dialog
with a "Cancel" button which allows the user to abort a background thread.
If the user clicks this button, I then want to prompt them to confirm the
cancellation. While the confirmation dialog is on-screen however, I want to
suspend the background thread until the user makes their decision. Is this
considered a dangerous approach however. The only other alternative I can
think of is to have my background thread periodically inspect some event
object (say, "AutoResetEvent") which the main GUI thread can [re]set as
required (the background thread will then start and stop accordingly). This
is an unwieldy approach IMO however and it also allows the background thread
to briefly continue its work until it gets around to checking the event. Any
comments would be appreciated. Thanks.