Both RunAsync
and ToTask
yield the very last value in the observable. Thus no value will be produced until the observable completes. But observables created with FromEventPattern
do not usually complete. You need to force them to complete with something like Take
or Until
.
I'll also note that RunAsync
and ToTask
are essentially redundant and there isn't need to do both.
In your case, I'll assume you are really interested in the first value that makes it through your filter:
var task = Observable
.FromEventPattern<MessageResponseEventArgs>(communicator, "PushMessageRecieved")
.FirstAsync(i => i.EventArgs.GetRequestFromReceivedMessage().Name == requestName)
.Select(i => i.EventArgs)
.ToTask();
task.Wait();