From f2105a64e1f2b8c8c3e8b03ec8b46dc7de008d67 Mon Sep 17 00:00:00 2001 From: Ben Barth Date: Wed, 8 Nov 2017 00:47:56 -0500 Subject: [PATCH] Create README.md --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..c3b2767 --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# wait +An obsessively simple and performant library for protecting critical sections. + +[![NuGet](https://img.shields.io/nuget/dt/wait.svg)](https://www.nuget.org/packages/wait/) + + +Let's look at some examples! Wait can be used using `Wait.On()` or `Wait.GetWaiter()`. + +#### Wait.On() +``` +Wait.On("critical section", () => +{ + // Critical Section + // Only one "critical section" will run at a time +}); + +new Thread(() => +{ + Wait.On("critical section", () => + { + // Critical Section + // Only one "critical section" will run at a time + }); +}).Start(); +``` + +#### Wait.GetWaiter() +``` +Waiter waiter = Wait.GetWaiter(); + +new Thread(() => +{ + // Downloading + waiter.Done(); +}).Start(); + +waiter.WaitUntilDone(); +// Download is done +```