Are you sure that the program simply does not close before you can see the result? Because it works great for me.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { private static void Main(string[] args) { Task.Factory.StartNew(Do); Console.Read(); } private static void Do() { Console.WriteLine("Hello from a thread"); } } }
Edit: Added a comment that I wrote in response to this, including my reasoning about why the text was not printed.
This is either because the application closes before the stream has the ability to display a string on the screen. It is also possible that you simply do not see it, because it closes right away. In any case, the reason it worked with the breakpoint is because you save the application longer.
source share