Skip to content

Instantly share code, notes, and snippets.

View tomachristian's full-sized avatar

Cristian Toma tomachristian

View GitHub Profile
@tomachristian
tomachristian / Program.cs
Created April 16, 2019 10:45
Throw when Wait is used on your Tasks
public class Worker
{
public Task DoWorkAsync() => ThrowOnBlockingTaskWaitPolicy.Execute(async () =>
{
await Task.Yield();
Console.WriteLine("doing some work");
await Task.Delay(1000);
@tomachristian
tomachristian / FutureDisposable.cs
Last active February 28, 2019 17:38
FutureDisposable
/// <summary>
/// A thread-safe disposable to act as a placeholder for a disposable that is not yet available.
/// </summary>
public sealed class FutureDisposable : IDisposable
{
private const int No = 0;
private const int Yes = 1;
private static readonly IDisposable AlreadyDisposed = new NoopDisposable();
@tomachristian
tomachristian / output
Created March 28, 2017 21:55
hauxir issue
$ node -v
v7.2.1
$ webpack -v
2.2.1
$ webpack
Hash: a4b355f414e9de6fe312
Version: webpack 2.2.1
Time: 4316ms
Asset Size Chunks Chunk Names
app.bundle.js 2.7 kB 1 [emitted] app
/// <summary>
/// Waits for the task to complete, unwrapping any exceptions.
/// </summary>
/// <param name="task">The task. May not be <c>null</c>.</param>
public static void WaitAndUnwrapException(this Task task)
{
task.GetAwaiter().GetResult();
}