Skip to content

Instantly share code, notes, and snippets.

View iluvadev's full-sized avatar
🍻
Trying to live

iluvadev

🍻
Trying to live
View GitHub Profile
@iluvadev
iluvadev / NonBlockingAction.cs
Created January 5, 2021 07:36
Execute actions without block entire application, Example: NonBlockingAction.Add(() => Console.WriteLine(line));
public static class NonBlockingAction
{
private static BlockingCollection<Action> _Queue = new BlockingCollection<Action>();
static NonBlockingAction()
{
var thread = new Thread(
() =>
{
while (true) _Queue.Take()?.Invoke();