I'm trying to send some POST requests to a server using RestSharp. However:
- The server takes about 20 seconds to process each request
- I don't want to lock up my GUI whilst I'm waiting for them to finish.
RestSharp has async functionality, so I've written this:
var handler = _restClient.ExecuteAsync(request, response =>
{
if(response.IsSuccessful)
{
Console.WriteLine("Success");
}
});
What I need to do is ensure that this happens on a separate background thread, as not to lock the GUI, and to wait for each response, check if successful, and then send the next one.
Any suggestions? A queue of some kind?