thread events

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I trigger event form thread and catch it in another thread

Simple scenario:

Thread "X" running …
Thread "Y" running …
Thread "X" triggering Event "W"
Thread "Y" catches Event "W"
Thread "X" running …
Thread "Y" processing Event "W"
Thread "Y" running …
Thread "X" running …
..
..
..
Can I implement this problem using normal event handling or am I forced to
use special way?!

C# preferred in code example
Thank you!
 
aibras said:
How can I trigger event form thread and catch it in another thread

C# events are not "catched", they are "run" by the thread that invokes
them. If you wish to run them asynchroneously you will have to use the
constructs available for async calls: Thread or .BeginInvoke.

You can have the event place data somewhere shared and use a Mutex or
the Monitor pattern to protect that shared data and communicate that
data is available.

Beware that the C# event concept has serious mutithreading problems,
read more about that in microsoft.public.languages.csharp.
Can I implement this problem using normal event handling or am I forced to
use special way?!
"Special"

C# preferred in code example

Is this homework?
 
Thank you Helge
Actually it is not homework.
It just problem I discuss it with my friend one day while dinner ^_^.
 
Back
Top