Would a Task.Convert extension method be useful or does it have hidden dangers?

Transforming the result of await ends up being annoying in terms of precedence I generally prefer to introduce a local var, but as you noted, that prevents expression-bodied methods. We occasionally forget ConfigureAwait(false) – this is solvable with tooling to some extent Since you’re working on a library and should use ConfigureAwait(false) everywhere, it may … Read more

Set ApartmentState on a Task

When StartNew fails you just do it yourself: public static Task<T> StartSTATask<T>(Func<T> func) { var tcs = new TaskCompletionSource<T>(); Thread thread = new Thread(() => { try { tcs.SetResult(func()); } catch (Exception e) { tcs.SetException(e); } }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); return tcs.Task; } (You can create one for Task that will look almost identical, or add … Read more

what does gulp-“cli” stands for?

The goal of gulp-cli is to let you use gulp like a global program, but without installing gulp globally. For example if you installed gulp 3.9.1 globally and your project testGulp4 has gulp 4.0 installed locally, what would happen if you run gulp -v into testGulp4? Without gulp-cli globally installed : CLI version 3.9.1 In … Read more

Waiting on a Task with a OnlyOnFaulted Continuation causes an AggregateException

You’re not waiting on a task with an OnlyOnFaulted continuation – you’re waiting on that continuation (returned by ContinueWith). The continuation is never going to fire because the original task returned normally, so it’s acting as if it were cancelled. Makes sense to me. I suspect you want to create the task, add the continuation, … Read more