Skip to main content

Posts

Featured

Reviewing Threads in C#

Review of multi-threaded C# applications. The oldest way to create a Windows thread uses the Thread object. public static class Program { Thread thread = new Thread(MethodCalledInThread); thread.Start(); thread.Join(); } public static void MethodCalledInThread() { Thread.Sleep(1000); } The Start method fires off the thread and the Join method waits until the thread is done.  The Sleep method just waits for the number of milliseconds in the parameter. By the way, don't ever do it this way .  Take a look at async / await which is usually the way to go. However, this is a review of using multi-threading in c#, so we march onward. Foreground versus Background Threads A process always continues to run as long as there is at least one foreground thread running in the process.  When there are not foreground threads running, then all background threads are forcibly terminated. Threads created using the Thread object above are foreground threads by default.  Y

Latest Posts

Finding Christ in a community of believers

Why do 85% of Catholics go to Mass these days?

Technical backend of MarchForLife.Net

Things have sure changed!

The Preaching of Pope Francis on the Sin of Self-Righteousness

Almost two years at Kennedy International

One year at Kennedy International

My new job and GIT

August 2016 Update

A Review of John Eldredge's Beautiful Outlaw.