Best way to return the exit code of a process run in a thread? [C# 2002]

Shaitan00

Junior Contributor
Joined
Aug 11, 2003
Messages
358
Location
Hell
Hopefully quick & simple question - I start a thread that launches a process and gets the ExitCode of that process and I need to somehow return that information (the integer exit code of the process) back to the UI which spawned the thread (and this can happen when the thread ends/terminates, no need to send it immediatly seeing as each thread is only responsible for launching a process they will end gracefully after getting the exit code anyways).

So - is there a nice way to return the exit code of a process launched from a thread to the UI (that spawned the thread)? Some way to return a value like we would do with a function for example?

I got it to work one way by creating a ReturnCode() delegate that I can launch as the last step in my Thread, this will pass the processes exit code from the thread to the UI but I'm not sure this is the best solution as there is no need to fire the delegate while the thread is running - maybe simply have the thread "return" the processes exit code?

Anyways - I was just wondering if there was a better way to accomplish this other then a delegate (which works fine) - any help would be much appreciated.
Thanks,
 
Back
Top