I am new to the thread model in .NET. What would you use to:
- Start a process that handles a file
(process.StartInfo.FileName = fileName;)
. - Wait for the user to close the process OR abandon the thread after some time.
- If the user closed the process, delete the file.
Starting the process and waiting should be done on a different thread than the main thread, because this operation should not affect the application.
Example:
My application produces an html report. The user can right click somewhere and say "View Report" - now I retrieve the report contents in a temporary file and launch the process that handles html files i.e. the default browser. The problem is that I cannot cleanup, i.e. delete the temp file.