Multithreading Best Practices

Multithreading requires careful programming. For most tasks, you can reduce complexity by queuing requests for execution by thread pool threads. This topic addresses more difficult situations, such as coordinating the work of multiple threads, or handling threads that block. Deadlocks and Race Conditions Multithreading solves problems with throughput and responsiveness, but in doing so it... Continue Reading →

Volatile and Thread.MemoryBarrier

Volatile variable and Thread.MemoryBarrier method use in condition when you want to access variable across threads without putting lock. You can read more about Volatile and Thread.MemoryBarrier on MSDN. Volatile keyword: Excerpts from MSDN The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock statement to... Continue Reading →

Multithreading Concept using .Net – Part III

Uses of Threads Foreground and Background Threads By default threads are foreground and if application is trying to close and if any foreground thread is running then application will close only after closing of all foreground threads, while background threads will automatically abort when all foreground threads will close. Therefore, you should use foreground threads... Continue Reading →

Multithreading Concept using .Net – Part II

Synchronization Concepts There are different strategies to make your thread safe or synchronize. Some of features are below: Basic Synchronization Thread .Sleep : Blocks execution for provided time period. Thread.Sleep(0) ; //will do context switch Thread.Sleep(100); // will block execution for 100 miliseconds Thread.Sleep(TimeSpan.FromMinutes(1)); // block for 1 minute Thread.Join : block thread execution until... Continue Reading →

Multithreading with C#

This is first post on using multithreading concepts .Net. I am discussing basic thing of multithreading in this post. First question in our mind is what thread is and why we should use it. A thread is independent execution path which run parallel with main tasks. A thread is contained inside a process and multiple... Continue Reading →

Powered by

Up ↑