kubemq-io / kubemq-CSharp

C# Library for KubeMQ server
MIT License
30 stars 8 forks source link

Fix bad async usage with wait on sync methods #20

Closed dust63 closed 1 year ago

dust63 commented 1 year ago

I experiment some trouble with the reject method on transaction class. When I analyse the source I can see that you used 'Wait()' on async method. This is bad practice in C#. It generate an AggregateException instead of the real exception. Calling async method on synchronous way is also a bad practices, and can create deadlock.

To fix that I create for each method, one async and one sync that call async method with GetAwaiter().GetResult(). It's more elegant, and allow developer to use async method in their implementations.

I also refactoring the code. I only touch the Transaction class.

kubemq commented 1 year ago

Hi, This usage of code is deprecated , please use the QueueStream instead.