C# Thread Syncornization

  • Thread starter Thread starter NvrBst
  • Start date Start date
N

NvrBst

Is there any internal thread variables/states I can set to request
stops? or I need to make my own global variables?

IE
-----------------------------
Thread myThrd = new Thread(new ParameterizedThreadStart(Func));
myThrd.Start(objParams);
*do stuff*
myThrd.ThreadState = ThreadState.SuspendRequested;
*do more stuff*
myThrd.ThreadState = ThreadState.Running
*do more stuff*
myThrd.ThreadState = ThreadState.AbortRequested
----------------------------- (Would be Ideal)
Then have myThrd just keep checking its state if the
"SuspenedRequested" is active (or AbortRequested) at certain points?
I can't set ThreadState though.


I can't find any "myThrd.RequestSuspened()" accessors either.

Is there better way than using global variables? (IE built in ones for
threads?) Thanks

NB
 
NvrBst,

You are better of using something like an event that the thread waits
on. This way, you have set points where you can synchronize the threads.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top