I'm following this tutorial on Udemy. The instructor has put this simple code on screen. And it's working on the instructor screen.
class Program
{
static void Main(string[] args)
{
Task.Run(() => Print());
Task.Factory.StartNew(() => Print());
//Print();
}
private static void Print()
{
for (int i = 0; i < 100; i++)
{
Console.WriteLine(i);
}
}
}
Nothing is happening for me. I don't see the numbers on the screen. Am I missing something? However, this code works, i.e. if I add the wait() method.
var t = Task.Run(() => Print());
t.Wait();
Thanks for helping