private static void TestFinallyCodeBlockOnThreadWorker() { _worker = new SingleThreadedRelayQueueWorker <Action>(a => a(), ThreadPriority.Normal, true, ApartmentState.Unknown); _worker.AddToExecutionQueue(() => { throw new Exception("oops"); }); _worker.AddToExecutionQueue(() => { throw new Exception("oops"); }); _worker.AddToExecutionQueue(() => { throw new Exception("oops"); }); }
private static void ThreadStart() { var threadId = Thread.CurrentThread.ManagedThreadId; Console.WriteLine("Thread " + threadId + " started, priority = " + Thread.CurrentThread.Priority); while (true) { _worker.AddToExecutionQueue(() => Console.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff") + " > Hello from thread " + threadId)); Thread.Sleep(500 - Thread.CurrentThread.Priority.ToInt() * 100); } }