Re: c# Thread problem
- From: "Jon Skeet [C# MVP]" <skeet@xxxxxxxxx>
- Date: Wed, 04 Jul 2007 02:31:38 -0700
On Jul 4, 10:27 am, cty0...@xxxxxxxxx wrote:
I have some question..
This is my first time to use thread..
Following code does not have error but two warring
The warring is
Warning 2 'System.Threading.Thread.Suspend()' is obsolete:
'Thread.Suspend has been deprecated. Please use other classes in
System.Threading, such as Monitor, Mutex, Event, and Semaphore, to
synchronize Threads or protect resources. http://go.microsoft.com/fwlink/?linkid=14202'
The warring are happened thread Resume/Suspend..
I'm not sure what is problem becuase thread programing is first time
for me...
As it says, you shouldn't use Suspend/Resume, basically. If you need a
producer/consumer queue (which it looks like this is) you can use Auto/
ManualResetEvent, or Monitor.Wait/Pulse/PulseAll. See the second half
of
http://pobox.com/~skeet/csharp/threads/deadlocks.shtml for an example.
You also shouldn't manually be calling Monitor.Enter/Exit - use lock
instead.
Finally, making a UI thread block at all is a bad idea - you won't be
able to do things like move the window while it's blocked. Instead,
you should either work asynchronously or have another thread waiting
for messages and calling Control.BeginInvoke or Control.Invoke to use
that message on the UI thread.
Jon
.
- Follow-Ups:
- Re: c# Thread problem
- From: cty0000
- Re: c# Thread problem
- References:
- c# Thread problem
- From: cty0000
- c# Thread problem
- Prev by Date: c# Thread problem
- Next by Date: Re: Accessing form controls
- Previous by thread: c# Thread problem
- Next by thread: Re: c# Thread problem
- Index(es):