Custom Event handling + thread handling.

  • Thread starter Thread starter Michael McCarthy
  • Start date Start date
M

Michael McCarthy

I've written an event that tells me that I've connected properly to a
remote telnet location. When I know that I'm connected I fire the event
which is being listened for in a bit of code that then goes on and does
some work based on this event.

My problem is that once I fire that event, the thread that fired it
waits until the thread that received it finishes. I fixed the problem
by making the bit of code that is listening for the event continue on
with what it is doing in the background, but I'm wondering if there is a
different way.

Specifically, the code is going through a csv file and then doing a few
things on a remote system to get information based on something in the
csv, and then processing that information once we get it.

Everything works fine, but I'd like to know what I'm doing wrong, in
that I don't think that the thread should be tied up waiting for
whatever was listening for the event to finish.

Any help, or pointing in the right direction is as usual, very much
appreciated.

regards,
M.
 
Hmmm. I was working on events on my screensaver, and I utilize events and I
noticed that the program output mentions that a separate thread that handles
events. I think it called it the NetEvent thread, which confirmed my
suspicion that events are handled on a separate thread.

My suggestion is to create a worker thread to start the event running, and
then when it is done, have the thread end.
 
Back
Top