Create An "event"?

Greetings -

I have several threads that take some time to run. They manage message transfer over IPC or tcpip sockets. There may be multiple exchanges between the thread and the remote application. I need a way to notify the host app that the thread has completed its task(s). It would be really nice if I could create an event when the thread closes or when it has data available or something like that. I’ve read over AddHandler and it does not appear to be the right tool for this task.

One, really klutzy way, might be to trigger a dedicated timer (not sure if this is a prohibited GUI access or not) that would then fire in some short time, raising its Action event. This, however, seems overly obtuse.

What do people do in such a situation?

Thanks
Jim Wagner
Oregon Research Electronics

One technique I’ve seen here is to set a Boolean flag in your thread object to true when the thread is finished with its work. Then create a timer which checks every nth microsecs for that bool.

if talk about sockets, you have probably no threads, but helper apps, right?

If you have threads, the GUI could have a timer which checks progress every few milliseconds and update gui, e.g. showing progress bar.

If you have helper app and talk with sockets, well the socket events happen on main thread and can show GUI updates.

Thanks -

And just saw the companion thread on basically the same subject.

I guess a status variable (maybe a property of the app) set by the thread and polled by a timer would work. Clumsy, but if it works, I can live with it.

Appreciate your input…

Jim