Message 1 of 4
C# HttpClient and asynchronous operations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm trying to use C#'s HttpClient methods in my Autocad plugin.
[CommandMethod("_MyCommand")]
public async void HttpClientTest()
{
using (HttpClient httpClient = new HttpClient())
{
using (HttpResponseMessage query = await httpClient.GetAsync(url))
{
if (query.IsSuccessStatusCode)
{
// ...
}
}
}
}
Problem is, as soon as the program reaches the first "await" statement, the command exits. I'm obvisouly lacking some understanding here, but is this due to the fact that Autocad doesn't handle multithreading?
And should I use synchronous operations tools (like C#'s WebRequest stuff) instead?