Base solution for your next web application
Open Closed

EventBus Async Hanlders #1865


User avatar
0
chrisk created

Hi there !

I started using EventBus in application and I'm using my DomainServices in IEventHandler<T> implementations. Thing is that all methods in my DomainServices are async using TPL.

Since handlers are non async void and I don't want to try adding async keyword to signature since its considered as very bad practice, what would you normally do in that case ?

  • I create non async version of methods that I need?
  • Use AsyncHelper.RunSync() ? how robust this solution is?
  • Other approach ?

All comments will be appreciated :)


2 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Use AsyncHelper.RunSync(). It's pretty robust. We didn't see any problem in our long term usage.

  • User Avatar
    0
    chrisk created

    Thank you for response :)

    It was confusing me for some time now - using TPL synchronously due to potential issues I could run into without broader knowledge of it.