Last active
December 16, 2015 12:29
-
-
Save renestein/5434943 to your computer and use it in GitHub Desktop.
Avoid lock in console - .Net 4.,5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://twitter.com/jechtom/status/326325740503175169 | |
using System; | |
using System.Threading; | |
internal class Program | |
{ | |
private static void Main(string[] args) | |
{ | |
Console.Error.WriteLine("Dummy error init"); | |
Console.WriteLine("Dummy init"); | |
Thread t = new Thread(SomeWorkingThread); | |
t.Start(); | |
while (Console.ReadKey().Key != ConsoleKey.Escape) | |
{ | |
} | |
} | |
private static void SomeWorkingThread() | |
{ | |
int i = 0; | |
while (true) | |
{ | |
Thread.Sleep(TimeSpan.FromSeconds(0.5)); | |
Console.WriteLine("Working... {0}", ++i); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment