I have been searching for an answer to this but cannot find a simple example to help me understand. I am writing win form app in c# that wraps up a bunch of command line tools used for video encoding. I have a method called encodefiles i want to run this method in a thread so that the UI can still operate. Once the thread has finished I want it to call another method so i know it has finished. i can then encode the next file or finish. all depends if there are any more files to encode.
I was getting the action i wanted when i was only running a single command line tool as i was using the process object which you can attach a finished event to. I want to the same for a thread but have no idea how.
In short i want to be able to do the following with a thread instead of a process
Process myProcess = Process.Start(commandLineExe, commandlineSwitches);
myprocess.EnableRaisingEvents = true;
myprocess.Exited += new EventHandler(myprocess_exited);
Hope that makes sense
Am using c# .NET 3.5 with visual studio 2010
well if you are using winforms and you want to run a task in background and notify when its completed use backgroundworker
and handle the DoWork(), WorkerComplete(), progressChanged() events to get your work done.