我在使用阻塞代码时遇到死锁Task.Wait(),等待async内部等待 Rx LINQ 查询的方法。
这是一个例子:
public void BlockingCode()
{
this.ExecuteAsync().Wait();
}
public async Task ExecuteAsync()
{
await this.service.GetFooAsync().ConfigureAwait(false);
//This is the RX query that doesn't support ConfigureAwaitawait
await this.service.Receiver
.FirstOrDefaultAsync(x => x == "foo")
.Timeout(TimeSpan.FromSeconds(1));
}
Run Code Online (Sandbox Code Playgroud)
所以,我的问题是是否有任何等效的 ConfigureAwait on awaitable IObservable 以确保延续不会在相同的SynchronizationContext.