Skip to content

Instantly share code, notes, and snippets.

@tamirs9876
Created August 18, 2019 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamirs9876/1a24475870217b1f1d440cd2d2df56f7 to your computer and use it in GitHub Desktop.
Save tamirs9876/1a24475870217b1f1d440cd2d2df56f7 to your computer and use it in GitHub Desktop.
using System;
using System.Threading.Tasks;
namespace ConsoleApp3
{
static class Test
{
private static readonly object Locker = new object();
static Test()
{
Do().Wait();
}
public static void SayHello()
{
Console.WriteLine("Hello Tamir!");
}
private static async Task Do()
{
await Task.Delay(1).ConfigureAwait(false);
lock (Locker)
{
Console.WriteLine("Inside the lock");
}
}
}
class Program
{
static void Main()
{
Test.SayHello();
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment