1 using System;
2 using System.Threading;
3
4 void ThreadFunction()
5 {
6 try
7 {
8 Console.WriteLine("thread sleeping 3 seconds");
9 Sleep(Duration.FromSeconds(3));
10 Console.WriteLine("thread exiting");
11 }
12 catch (const Exception& ex)
13 {
14 Console.Error() << ex.ToString() << endl();
15 }
16 }
17
18 void main()
19 {
20 try
21 {
22 Console.WriteLine("starting thread");
23 Thread thread = Thread.StartFunction(ThreadFunction);
24 thread.Join();
25 Console.WriteLine("main exiting");
26 }
27 catch (const Exception& ex)
28 {
29 Console.Error() << ex.ToString() << endl();
30 }
31 }