LINQpad Stream Behavior

I was just getting started with LinqPad and trying some snippets of the stream in it and I was confused as to why my code is not doing as expected.

Thread t1 = new Thread
        for (int cycles = 0; cycles < 1000; cycles++)
            Console.WriteLine("Hello World!");



Why is it just a print Soham

. The code block inside the thread is not executed at all. I can't figure out why, because the syntax compiles just fine, and as far as I know about C # this should compile fine and work in VS2010 and execute both outputs, although the order cannot be determined. What am I doing or thinking is wrong. I may need some helpful guides and suggestions to get used to LinqPad.


source to share

1 answer

Try adding t1.Join()

after Console.WriteLine("Soham")

:-) LINQPad probably sees the main thread shutting down and killing everything. With this, the t1.Join();

main thread will wait for another thread to complete.

Ah ... and just tested it :-)

I'll add that you can write fewer characters:

new Thread(() => 




All Articles