Multiple threads and events.

  • Thread starter Thread starter Francisco K. do Amaral
  • Start date Start date
F

Francisco K. do Amaral

Hi I'm working with threads and events. Several threads of a method in my
code can launch a event that will be captured by only one component (another
class).
This is a problem to me?? There is a stack of events that will be executed
sequentially??

Thanks.
 
Hi,

You event handling code will be executed in context of the thread that fired
the event.

If you want to handle events from one (or more) thread in the another thread
you can do the following:
1. Write a class that will handle event in the source thread and queue event
data in place shared between all threads (this require synchronization
code);
2. Write a class that will work in the target thread and will receive queued
event information (this require synchronization code). This class will
re-launch the event in the context of the target thread using event
information.

This approach describe asynchronous model. You can modify it and make it
synchronous.
 
Back
Top