Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
35 lines (28 loc) · 1.24 KB

File metadata and controls

35 lines (28 loc) · 1.24 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
namespace Npgsql.Util;
readonly struct TaskSchedulerAwaitable(TaskScheduler scheduler) : ICriticalNotifyCompletion
{
public void GetResult() {}
public bool IsCompleted => false;
public void OnCompleted(Action continuation)
{
var task = Task.Factory.StartNew(continuation, CancellationToken.None,
TaskCreationOptions.DenyChildAttach,
scheduler: scheduler);
// Exceptions should never happen as the continuation should be the async statemachine.
// It normally does its own error handling through the returned task unless it's an async void returning method.
// In which case we should absolutely let it bubble up to TaskScheduler.UnobservedTaskException.
OnFaulted(task);
[Conditional("DEBUG")]
static void OnFaulted(Task task)
{
task.ContinueWith(t => Debug.Fail("Task scheduler task threw an unobserved exception"), TaskContinuationOptions.OnlyOnFaulted);
}
}
public void UnsafeOnCompleted(Action continuation) => OnCompleted(continuation);
public TaskSchedulerAwaitable GetAwaiter() => this;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.