J
JAM
Is there a way to trigger event such that the event is triggered in
one thread and the event delegate is executed by another ?
I'm guessing here, but I think that when thread triggers the event it
is also the same thread that executes the delegate attached to the
event. Am I right here ?
If the above is true, then id does not works fo me. What I need is
more or less described below.
Let's say that my main ThreadA creates a class, which has an event and
couple of methods and a delegate method to handle some action, that
the Thread A attaches to the event in the class constructor. Once its
all done, initialized etc., ThreadA then creates bunch of children
threads: ThreadB, ThreadC, ThreadD etc, to run some methods of the
class in parallel. My program need ThreadB, C, D etc to signal some
events back to the ThreadA such that the ThreadA executes then some
action. It must be a ThreadA because it involves managing all other
threads, interface, etc. But of course I don't want ThreadA wasting
cycles and waiting in the loop constantly monitoring if its children
threads reached particular point in it's execution. My ThreadA is the
main application thread which is servicing user interface so putting
it to sleep or waiting in the loop is not an option. I would prefer
some signal to be send back to ThreadA (like message in the good old
Windows) so it react then to the event by executing delegate.
Is it possible to do it and how roughly to do it ?
JAM
one thread and the event delegate is executed by another ?
I'm guessing here, but I think that when thread triggers the event it
is also the same thread that executes the delegate attached to the
event. Am I right here ?
If the above is true, then id does not works fo me. What I need is
more or less described below.
Let's say that my main ThreadA creates a class, which has an event and
couple of methods and a delegate method to handle some action, that
the Thread A attaches to the event in the class constructor. Once its
all done, initialized etc., ThreadA then creates bunch of children
threads: ThreadB, ThreadC, ThreadD etc, to run some methods of the
class in parallel. My program need ThreadB, C, D etc to signal some
events back to the ThreadA such that the ThreadA executes then some
action. It must be a ThreadA because it involves managing all other
threads, interface, etc. But of course I don't want ThreadA wasting
cycles and waiting in the loop constantly monitoring if its children
threads reached particular point in it's execution. My ThreadA is the
main application thread which is servicing user interface so putting
it to sleep or waiting in the loop is not an option. I would prefer
some signal to be send back to ThreadA (like message in the good old
Windows) so it react then to the event by executing delegate.
Is it possible to do it and how roughly to do it ?
JAM