All Questions
128 questions
1
vote
2
answers
1k
views
What happens with unhandled exceptions for 'Fire and Forget' tasks for C# Restful APIs?
I am making some code changes for a restful API service, in particular making some notification events completely async, so that a response can be returned without the caller needing to wait for the ...
1
vote
1
answer
1k
views
How to catch an exception in a task?
In the following example exception is not intercepted and the program keeps running as if nothing happened. Is there a global error handler that can intercept such exceptions?
Here's playground link.
...
2
votes
1
answer
767
views
How to crash on unhandled Task exception?
I'd like to properly understand the consequences of failing to observe an exception thrown on a Task used in a fire and forget manner without exception handling.
Here's an extract from CLR via C#, ...
2
votes
3
answers
922
views
How to access a variable that was available when an async method was called?
The animal names are fetched from an API that could return 404 if the animal is not found. But in order to properly log the error, we need to have access to the animal's country. Is it possible? I've ...
0
votes
0
answers
88
views
What is the fate of a Task that is in limbo because another Task in same scope threw exception? [duplicate]
In situation 1, taska and taskb are in the same scope. taska bites the dust and we leave this scope prematurely. What becomes of taskb? To put it another way: mechanically, how does the Framework/OS ...
-1
votes
2
answers
71
views
Interrupt calling thread when exception in child task
I have the following scenario:
I have a plugin class (unfortunately synchronous and that's out of my control) which runs automation scripts. At startup, a task is started which runs in the background ...
0
votes
1
answer
113
views
Is this correct way to handle an exception?
I've argued with my colleague about handling exceptions in Task.Run blocks.
For example, I have this code:
private static async Task MainAsync()
{
try
{
await Task.Run(() => throw ...
0
votes
1
answer
52
views
Catching exceptions from complex chains of tasks
I have a .Net core app that basically does something like this:
public async Task<IOBoundStuffResult> DoIOBoundStuff()
{
// Do IO bound stuff ...
return new IOBoundStuffResult
{
...
1
vote
2
answers
510
views
How to wrap all exceptions of an ActionBlock in a single AggregateException
I came across TPL ActionBlock which seems to be pretty handy for (throttled) parallel async operations. So far I am using Task.WhenAll() (+ Semaphore for throttling). When it comes to exceptions there ...
0
votes
0
answers
189
views
Catching exceptions when using async/await and ContinueWith
I'm building a generic abstract class (.NET Framework 4.6.1) that will get items from a work queue (Amazon SQS in this case but ultimately the source is unimportant) and do some sort of processing on ...
0
votes
2
answers
589
views
How to capture and handle unhandled exceptions that happens inside Task.Factory
I have coded this inside App startup
inside App.xaml.cs
public App()
{
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += new ...
0
votes
1
answer
115
views
Task Exception not caught
With the following code I only catch the exceptions in the ContinueWith action and not with the try-catch block. Does anyone have an idea why I can't catch with try-catch? As I understand the ...
2
votes
4
answers
2k
views
A simpler way of ignoring specific types of exceptions when awaiting a Task
When awaiting a Task I would like to have an easy way to ignore specific types of exceptions, like OperationCanceledException or TimeoutException or whatever. I got the idea of writing an extension ...
1
vote
1
answer
4k
views
Asp.Net Core Razor Pages Exception Handling breaks the application
I'm building an Asp.Net Core 2.2 Razor Pages Application. I'm writing an global exception handling to avoid try catch blocks in many places. I followed the article - Exception Handling Reference
Here ...
0
votes
1
answer
691
views
MethodAccessException on Task.CompletedTask property
I am working on a small wpf application and one of the users is getting the following exception:
System.MethodAccessException:
Attempt by method "xxx.HttpConfirmation.Invoke()" to access method "...