473,287 Members | 1,643 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

C# Thread Syncornization

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

Jul 2 '07 #1
1 1475
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"NvrBst" <nv****@gmail.comwrote in message
news:11**********************@o11g2000prd.googlegr oups.com...
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

Jul 2 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: adeger | last post by:
Having trouble with my first forays into threads. Basically, the threads don't seem to be working in parallel (or you might say are blocking). I've boiled my problems to the following short code...
4
by: Gilles Leblanc | last post by:
Hi I have started a small project with PyOpenGL. I am wondering what are the options for a GUI. So far I checked PyUI but it has some problems with 3d rendering outside the Windows platform. I...
7
by: Ivan | last post by:
Hi I have following problem: I'm creating two threads who are performing some tasks. When one thread finished I would like to restart her again (e.g. new job). Following example demonstrates...
4
by: Matthew Groch | last post by:
Hi all, I've got a server that handles a relatively high number of concurrent transactions (on the magnitude of 1000's per second). Client applications establish socket connections with the...
5
by: Razzie | last post by:
Hi all, A question from someone on a website got me thinking about this, and I wondered if anyone could explain this. A System.Threading.Timer object is garbage collected if it has no...
16
by: droopytoon | last post by:
Hi, I start a new thread (previous one was "thread timing") because I have isolated my problem. It has nothing to do with calling unmanaged C++ code (I removed it in a test application). I...
9
by: mareal | last post by:
I have noticed how the thread I created just stops running. I have added several exceptions to the thread System.Threading.SynchronizationLockException System.Threading.ThreadAbortException...
1
by: srikanthmuvva | last post by:
i creatd a groove syncornization for one of my folder how i will able to remove this from the groove syncornization?
2
by: srikanthmuvva | last post by:
i need some information abou the groove syncornization
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.