Skip to content

felipegtx/SimpleLocker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleLocker

A simple concurrency controller for .Net

/// This is your thread-"unsafe" object
var list = new List<int>();

/// We use the simple locker instance
var locker = new SimpleLocker();

Parallel.For(0, 10000, i=>
  {
    /// Safelly modify it
    locker.WriteVoid(() => list.Add(i));

    /// Safelly ready it
    Console.WriteLine("CurrentCount {0} - ThreadId: {1}", locker.Read(() => list.Count), 
      Thread.CurrentThread.ManagedThreadId);

  });

Console.WriteLine ("Done!");
Console.ReadLine ();

About

🔐 A simple concurrency controller for .Net

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages