C
CirclesTraveled
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...
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...