I am working on a winforms application with async methods. On an event i call multiple series of async methods. Unfortunately, the application freezes. My async calls are all awaited but i couldnt figure out what caused the deadlock.
Winforms block
private async void sendMessages_Click(object sender, EventArgs e)
{
await ServiceFacade.SendMessage("Hi to CEO");
await ServiceFacade.SendMessage("Hi to Manager");
await ServiceFacade.SendMessage("Hi to Team Leader");
}
My library class which sends data to an api
public class ServiceFacade
{
public async Task SendMessage(string message)
{
//validates and formats message then calls PostAsync to send it on api service
await PostAsync(string message);
}
private static async Task PostAsync(string message)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("hostname.com")
//set up REQUEST ...
var response = (HttpWebResponse)await request.GetResponseAsync();
}
}