As a rule, Windows is set to hibernate or even hibernate when there is no long time from the user (by default - about 15-30 minutes).
Given that he stayed all night, he could fall asleep and stop all the processes. So, basically the thread worked for a while, but later it was suspended due to the computer entering sleep mode. And this did not work in the remaining time. When you returned, the flow resumed, but the application soon shut down. In other words, the machine did not work most of the time, and the thread did not have time to run to the end. And by disabling the application, you just stopped it completely.
The following is a replacement for your HelperMethods.Mymethod , it runs in a separate background thread, as in your case:
while(i < 1000) { Console.WriteLine(DateTime.Now); i++; Thread.Sleep(1000); }
When I started it and turned on the car to sleep - this is the result that I get.
4/21/2015 6:00:45 PM 4/21/2015 6:00:46 PM 4/21/2015 6:00:47 PM 4/21/2015 6:00:48 PM *** gap here. machine is in sleep, thread not working *** 4/21/2015 6:01:02 PM 4/21/2015 6:01:03 PM 4/21/2015 6:01:04 PM
Also, calling your Mymethod methods is a bad idea. The method name must be descriptive. It should be easy to understand what he is doing without looking into him.
source share