ShevaKadu
ShevaKadu
CC#
Created by ShevaKadu on 8/12/2024 in #help
Visual Studio has dementia
I was working on a WPF project, then I closed Visual Studio. When I opened Visual Studio again, it showed me 10 incorrect errors, which all were The name ... does not exist in the current context.. This happened by itself, I did not break anything. Trying to build with the code-behind tabs open fails but works if I close them.
10 replies
CC#
Created by ShevaKadu on 8/10/2024 in #help
✅ HTTPClient's GetAsync errors and doesn't get caught
In this code
c#
private async Task<CheckResult> TestHTTP()
{
...
// above code creates httpclient as client
try
{
(!) response = await client.GetAsync(expectedURL);
}
catch (TaskCanceledException ex) when (ex.InnerException is TimeoutException)
{
client.Dispose();
handler.Dispose();
return CheckResult.TimedOut;
}
catch
{
client.Dispose();
handler.Dispose();
return CheckResult.TimedOut;
}
...
}
c#
private async Task<CheckResult> TestHTTP()
{
...
// above code creates httpclient as client
try
{
(!) response = await client.GetAsync(expectedURL);
}
catch (TaskCanceledException ex) when (ex.InnerException is TimeoutException)
{
client.Dispose();
handler.Dispose();
return CheckResult.TimedOut;
}
catch
{
client.Dispose();
handler.Dispose();
return CheckResult.TimedOut;
}
...
}
client is a Httpclient which is supposed to timeout after a delay. To test that, I tried getting it to access a URL that doesn't work. client.GetAsync( ).Result throws a TaskCancelledException , which doesn't get caught Adding:
This function is supposed to be used in multiple threads. Maybe having the thread error out and shutdown serve as a "catch" block of sorts can work? However that is not optimal
How fix???:kekw:
52 replies