Using events in worker threads

May 16 2007 4:43 PM

I've got a question that maybe some of the more seasoned programmers on this board can answer for me. I've tried to do some googling on the subject, but I haven't found anything that provides a concrete answer to what I'm looking to find out. Here's a short-ish breakdown of my situation:

My application is an interface for a Rimage disc-burning server. It basically monitors a folder on the file system and waits for folders (patient studies to be burned to cd) to be dropped into this target directory.

Once a study is detected, it is moved to a temp folder for processing, at which point an order ticket is created and a worker thread is spawned to submit the order and monitor its progress.

Currently, this worker thread runs in a constant while loop that checks a state property of the order to advance through a set of internal conditionals based on that state property.

What I am wondering is if I were to remove the while loop and set up events on the order itself to move the process along, will the worker thread exit if it reaches the end of its method call and is left waiting for events to trigger?

I apologize if any of my explanation is unclear, I'm a fairly novice programmer and don't quite know how to explain things in a precise technical manner. Please let me know of anything that needs further clarity, as I'm really curious about this issue.

Thanks in advance


Answers (1)