Skip to content
MAKOLYTE

MAKOLYTE

Solve real coding problems

  • About
  • C#
    • String
    • Dictionary
    • List
    • DateTime
    • Enum
    • Reflection
    • HttpClient
    • JSON
    • XML
    • EF Core
    • Dapper ORM
    • File IO
    • WinForms
  • ASP.NET Core
    • appsettings.json
    • Model Validation
  • Visual Studio
  • Unit Testing
  • SQL
    • SQL Server
    • MySQL
  • Other
    • Frontend
    • HackerRank
    • Java
    • Postman
    • PowerShell
    • Refactoring
  • Contact Us

Threading

Articles about writing multithreaded code in C# and using threading constructs such as locks and signals.

C# – Thread-safe bool properties using Locks vs Interlocked

02/07/202312/06/2020 by Maclain Wiltzer

The following bool property is not thread-safe. Why is this thread un-safe? Let’s say you have two threads running at the same time. One thread is reading the bool property, while the other thread is changing the value from false to true. It’s possible for the reader thread to get the stale value (false instead … Read more

Categories C#, Threading 4 Comments

C# – ManualResetEventSlim and AutoResetEvent

03/08/202312/03/2020 by Maclain Wiltzer

When you want thread(s) to wait until they’re signaled before continuing, there are two simple options: I’ll show examples of using both of these. ManualResetEventSlim examples ManualResetEventSlim is like waving a flag at a car race. All race cars (threads) line up at the starting line and wait for the flag, and then they all … Read more

Categories C#, Threading Leave a comment

C# – Use SemaphoreSlim for throttling threads

02/07/202306/30/2020 by Maclain Wiltzer

When you have multiple threads trying to do work at the same time, and you want to throttle how many of them are actually executing, you can use SemaphoreSlim. Example – a busy grocery store Grocery stores have a limited number of checkout lanes open. Let’s say the grocery store has two lanes open, and … Read more

Categories C#, Threading 3 Comments
  • Makolyte's Twitter Profile
  • Makolyte's LinkedIn Page
  • Makolyte's GitHub Profile
About • Contact Us • Privacy Policy
© 2023 MAKOLYTE • Built with GeneratePress