Threading in .Net...

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hello Everyone,

I have to write a program that uses multiple threads. Simply, this is
what I want to do.

1) The parent thread will spawn at least two child threads.
2) Child Thread 1 will monitor data from a source and if the
conditions are TRUE, it would post a message to the top of a message
queue. Then alert Child Thread 2 that there is a message in the queue.
3) Child Thread 2 would pop the tail of the message queue until all
the messages have been processed and reported to the user.

Normally in C++ or Delphi, I would use a Critical Section variables
around the global memory structure that would prevent more than one
thread accessing the data in memory at the same time and use windows
postmessage events to notify the thread that it needs to look at the
message queue. Unfortunately, I can not use C++, Dephi or C#. I have
to use VB .Net. The good thing about .Net is the fact that it supports
threading. 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?

Thank you in advance...

.



Relevant Pages

  • Re: Threading in .Net...
    ... The parent thread will spawn at least two child threads. ... Then alert Child Thread 2 that there is a message in the queue. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Question about the example in perlthrtut
    ... So the first thread will not complete untill the last thread ... This first thread has a full queue and the joinblocks ... First thread creates a new second child thread and passes the prime 3 and an empty queue ... I don't know how threads are implemented in Perl too well. ...
    (comp.lang.perl.misc)
  • Re: 1.9.x Thread problem
    ... or the creating parent thread, ... which I can guarantee I am running in the first created child thread? ... the Queue, so I should _only_ get child Thread instances when I call ... altered or corrupted during transmission. ...
    (comp.lang.ruby)
  • Re: Threading in .Net...
    ... The parent thread and the worker thread. ... I assume that you are using the queue class. ... The parent thread will spawn at least two child threads. ... Then alert Child Thread 2 that there is a message in the queue. ...
    (microsoft.public.dotnet.languages.vb)