Reputation: 1286
The program I am working on is used to test operations in a time-based schedule. As such, one of the requirements is to change the system clock to provoke another application into firing events. This is simple enough. My program runs a script, which can set the clock. When the script starts, I store the DateTime.Now and create a Stopwatch. When the script ends, if it has modified the system clock I read the elapsed time, add it to my start time, and set the system clock that value. All fine so far. HOWEVER. If I debug my program and stop it before the script ends, that restore never happens. I was wondering if there was any way to get the C# debugger to forcibly call some piece of code (or perform some action such as reading the time from an NIST server) when it shuts down?
Upvotes: 1
Views: 158
Reputation: 10316
"I debug my program and stop it..."
So you're wondering why your program doesn't continue after you've stopped it?
You can debug your program and then simply detach the debugger when you're done - this will leave the program running.
Upvotes: 1
Reputation: 7411
Stopping the debugger is the same as terminating the process, so there is no guarantee, what is happening.
Nevertheless consider to implement a dispose or a finalize method.
Upvotes: 1