Multithreaded events in dll to prevent blocking

G

Guest

I have a synchronous socket dll which fires several events to a winforms
client.
The winform calls methods on the dll and the dll fires an event back on the
same thread. I want the dll to fire events back on a different thread, but
am not sure how to go about this.

The dll has many events,, each event has different event arguments, so must
I create a thread for each event?

Without these threads, my winform app sometimes seems to "miss" the events
fired from the dll.

Can anyone guide me with some sample code? Perhaps a url demonstrating this?

Thanks
 
J

John Saunders

Opa said:
I have a synchronous socket dll which fires several events to a winforms
client.
The winform calls methods on the dll and the dll fires an event back on
the
same thread. I want the dll to fire events back on a different thread,
but
am not sure how to go about this.

Events are always fired on the same thread as the code raising the event. If
this might be a different thread from the one containing the message loop,
then the event handler must use Form.Invoke. Otherwise, you'll see the kind
of problem you've seen.

John Saunders
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top