/ Published in: C#
Run without a debugger in debug mode and release mode. Different behavior.
Expand |
Embed | Plain Text
class Program { static void Main(string[] args) { bool stop = false; { Thread.Sleep(2000); stop = true; Console.WriteLine("Set \"stop\" to true."); }).Start(); Console.WriteLine("Entering loop."); while (!stop) { } Console.WriteLine("Out of loop. Finished."); } }
Comments
Subscribe to comments
You need to login to post a comment.

Wow, although it kind of makes sense because Stop will lose focus when it goes in to a separate function. If you make Stop static, and declare it outside the main function, both versions respond the same.