Re: Threading in .Net...



On 6 Jun 2006 12:12:57 -0700, CirclesTraveled wrote:

It is very easy to create threads and start them in .Net.
However, the way it provides messaging between threads is a little
confusing to me or I might be just over analysing it. I could use
monitor like the critical section variables to protect the global
memory structure, but how I do I notify Child Thread 2 that there is a
message waiting in the Queue.

What is the recomended way to do this in .Net?

Use a ManualResetEvent. Have thread 2 wait on it. In thread 1, when a new
item is placed on the queue, set the event. This will Cause thread 2 to
wake up. Then thread 2 can do it's job and process all the items in the
queue. When it's done it can reset the ManualResetEvent and wait until
woken up again.
.



Relevant Pages

  • Re: Thread Checking the Queue data in an infinite loop
    ... Note that IOCPs don't have "spurious wakeups". ... I've done some fairly intense high-performance interthread messaging using IOCPs, ... access to the Queue. ...
    (microsoft.public.vc.mfc)
  • Re: PeekMessage, DispatchMessage in C# ??
    ... I have a queue q. ... is a simple callback mechanism that is described as messaging. ... > time (thread concurrency control) you should be ok. ... >> Hi Alex, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Thread Communication in C#
    ... If I use ManualResetEvent, I still need some way to pass data between the ... sure how to pass the reference to the queue to the sub thread at start. ... >> GetMessage. ... >> Pipes and GetMessage both did. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Mutex misunderstanding
    ... ManualResetEvent instead. ... private Queue myQ = new Queue; ... lock ... Task RemoveFromQ() { ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: dont completely get it with JMS ...
    ... The deal with JMS is that there are at two different, ... Other vendors support Topic style Messaging. ... A one-to-one relationship is supported by a Sender placing a message ... Session is used by both the Queue and Topic receivers, ...
    (comp.lang.java.programmer)