Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RunSynchronously exception on RESTActionConsumer.cs #43

Merged
merged 4 commits into from
Aug 8, 2017

Conversation

alejogagliardi
Copy link

Hi, i have compiled branch master because i need to use OnPeerStatusCangeEvent, what is not present in NuGet package ver 1.1.0, and i had got an exception of "run synchronously may not be called on a task unbound to a delegate" on result.RunSynchronously perhaps due a synchronization context problem. I was able to solve the problem using result.GetAwaiter().GetResult();

Hope this help

Best regards

@skrusty
Copy link
Owner

skrusty commented Jul 28, 2017

HI, thanks for your contribution.

I am not the worlds best with async, so any ideas why GetResult() works and not RunSynchronously() ?

Cheers,
Ben

@alejogagliardi
Copy link
Author

Hi, Ben, sorry for the delay on answer. It´s the first time i had used this method, Ithink the task may by wrapped within a Func delegate to bound the task to an delegate, i has don't try this yet. Another alternative it´s run the task directly with "Run" and call wait on this task, I think you can ommit the wait method because the "result.Result" call will block until "Result" becomes available.

@alejogagliardi
Copy link
Author

Ben, I forgot to mention that if the task thrown an exception if you used GetAwaiter.GetResult you will get that exception otherwise, by calling Wait or Result you will have an AggregateException and you must inspect that in order to know what happened.

@skrusty
Copy link
Owner

skrusty commented Aug 3, 2017

Yes, I had read the same about the AggregateException.

Cheers, Ben

@skrusty skrusty mentioned this pull request Aug 8, 2017
@skrusty skrusty merged commit 0babcfa into skrusty:master Aug 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants