morpheums/Binance.API.Csharp.Client

CPU Pegged when running as a GUI

Closed this issue · 3 comments

Thank you for writing this client! I am able to connect when I use the console; however, when I use a Win Forms or WPF, it seems to stall and lock the CPU. Any ideas?

image
image

same issue here

The problem is that you are locking the UI thread by calling it that way from your method, there are 2 options to avoid Deadlocks, the first option you must mark your method with the "async" modifier, the second you just have to use "Task.Run":

  • Option 1 (Using the "async" method): var serverTime = await binanceClient.GetAllPrices()

  • Option 2: var serverTime = Task.Run(() => binanceClient.GetServerTime()).Result;

Please let me know if this worked for you so i can close the ticket, thanks!

That worked perfectly for me. I figured it was something I was doing. Thanks for the quick response!