// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; using System.Threading; class MainClass { public static void Main(string[] args) { try { Thread t = new Thread(new ThreadStart(DoSomething)); t.Start(); } finally { StreamWriter sw = new StreamWriter(@"C:\z.txt", true); sw.WriteLine("Finally"); sw.Close(); } } public static void DoSomething() { Thread.Sleep(5000); StreamWriter sw = new StreamWriter(@"C:\z.txt", true); sw.WriteLine("Thread"); sw.Close(); } }