Difference between revisions of "Threads"
From MyWiki
(Created page with " using System; using System.Threading; namespace Chapter1 { public static class Program { public static void ThreadMethod() { for (int i =...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | <source lang="csharp"> | |
using System; | using System; | ||
using System.Threading; | using System.Threading; |
Latest revision as of 21:12, 23 June 2014
using System; using System.Threading; namespace Chapter1 { public static class Program { public static void ThreadMethod() { for (int i = 0; i < 10; i++) { Console.WriteLine("ThreadProc: {0}", i); Thread.Sleep(0); } } public static void Main() { Thread t = new Thread(new ThreadStart(ThreadMethod)); t.Start(); for (int i = 0; i < 4; i++) { Console.WriteLine("Main thread: Do some work."); Thread.Sleep(0); } t.Join(); } } }