SteamQueryNet icon indicating copy to clipboard operation
SteamQueryNet copied to clipboard

How to handle exceptions?

Open Coke21 opened this issue 4 years ago • 1 comments

Hi, I'm trying to use your library instead of QueryMaster. I cannot get my head around handling exceptions if the server is e.g. offline. The following code:

IServerQuery serverQuery = new ServerQuery($"{serverModel.ServerIp}:{serverModel.ServerQueryPort}");
ServerInfo info = await serverQuery.GetServerInfoAsync();

If the server is offline it will get "stuck" on ServerInfo info = await serverQuery.GetServerInfoAsync(); and wait infinitely? at this line of code. With QueryMaster, it just returned null so I could see that the server is offline. How can I handle this with your library? Thanks for help.

Coke21 avatar Jun 05 '20 13:06 Coke21

I've made a pull request where you can handle timeout exceptions like this

image

RestoreMonarchy avatar Jun 06 '20 21:06 RestoreMonarchy