Calling Web APIs from a Windows Forms Application

http://www.asp.net/web-api/overview/web-api-clients/calling-a-web-api-from-a-net-client

I used this tutorial to learn how to send and retrieve data from the Internet API. However, is there another way without using Tasksand await? Sometimes my requests take a long time to return when others are relatively fast.

Are there any other tutorials that can help? What is the best way to call my web client APIto login? I feel that I must not be used awaitand asyncfor this sort of thing, but could really use some help.

+4
source share
2 answers

just load microsoft http api library from nuget manager into your project and use httpClient

+4
source

You can simply use HttpClientit if you want, and it is supported even in older versions .NET, and you will not need to worry about tasks or threads. HttpClientalso allows you to get the result async, but you will need to provide callbackfor the call when the result is ready.

Take a look at http://msdn.microsoft.com/en-us/library/system.net.http.httpclient(v=vs.110).aspx

Having said that, I agree with John's comments above that you should use awaitandasync

0
source

Source: https://habr.com/ru/post/1532063/


All Articles