c# - ConfigureAwait for IObservable<T> -
i'm experiencing deadlock when use blocking code task.wait(), waiting async method inside awaits rx linq query.
this example:
public void blockingcode() { this.executeasync().wait(); } public async task executeasync() { await this.service.getfooasync().configureawait(false); //this rx query doesn't support configureawaitawait await this.service.receiver .firstordefaultasync(x => x == "foo") .timeout(timespan.fromseconds(1)); } so, question if there equivalent configureawait on awaitable iobservable ensure continuation not resumed on same synchronizationcontext.
you have comprehend "awaiting observable" means. check out this. so, semantically, code
await this.service.receiver .firstordefaultasync(x => x == "foo") .timeout(timespan.fromseconds(1)); is equivalent to
await this.service.receiver .firstordefaultasync(x => x == "foo") .timeout(timespan.fromseconds(1)) .lastasync() .totask(); (note there kind of redundance here, calling firstordefaultasyncand lastasync that's no problem).
so there got task (it can take additional cancellationtoken if available). may use configureawait.
Comments
Post a Comment