All Questions
119 questions
1
vote
1
answer
696
views
C# - How to solve the "Interceptors failed to set a return value, or swallowed the exception thrown by the target" error?
Cannot seem to get the last piece of the puzzle into place. Appreciate any assistance :)
I have an interceptor that is logging the parameters and the return of the methods that I want to intercept. ...
1
vote
1
answer
752
views
Exception handling in Open.ChannelExtensions pipelines
I'm having issues with proper handling of exceptions thrown from pipeline steps created using Open.ChannelExtensions library. In some scenarios exception is being swallowed instead of being propagated ...
5
votes
1
answer
720
views
.net and Parallel.ForEach. Exception bypass the "try" block [duplicate]
Can somebody explain the behaviour of this code:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello world");
try
{
...
2
votes
1
answer
435
views
Converting sync to async code got unhandled System.OperationCanceledException: 'The operation was canceled.'
I'm trying to convert my sync functions to async. In all my sync functions I have a cancellation token which is used on function, task and parallel blocks. I have a try/catch block before calling the ...
1
vote
1
answer
826
views
Handling task timeout and exception
I have a certain Func<bool> func in C# (.NET Framework 4.8) in a WPF application and want it to be executed. I'd like to have a method that takes this kind of Funcs and returns a bool.
It ...
0
votes
0
answers
73
views
Why this program stop running? Await exception handling and canceling issue
I was given a task to write asynchronous console application, and faced problem with "await" exception handling. The task is that I need to perform some specific calculations asynchronously, ...
2
votes
1
answer
4k
views
Exception thrown in async method is not caught - why?
I have a hard time understanding how async/await works in various non-happy-path cases. For example, I have the following code:
class Program
{
static void Main(string[] args)
{...
2
votes
1
answer
1k
views
Exit the application with exit code from async thread
My .NET5 Web API project (in addition to REST) listens to Telegram messages. The goals are simple:
when a user sends exit message - terminate the app with exit code 8
when a message handler throws a ...
1
vote
2
answers
1k
views
C# what is the risk of calling an async method and never awaiting the returned task or storing references to said Task
I know that exception handling can become strange if you never await a returned Task, but if you don't actually care about the results and/or the success of the async method, does it matter if you don'...
0
votes
1
answer
847
views
Catching OutOfMemory Exceptions from HttpClient.GetAsync()
I am performing a fairly simple HttpClient.GetAsync() call, and if the target of my call exists (it is a Web Service running on my local PC) then I get back data correctly and everything works as ...
0
votes
1
answer
774
views
Catching exception of an invoke async method C# [duplicate]
I'm trying to get an exception from an async method that I need to invoke, example:
public async Task MyFirstMethod()
{
await Check(() => Test("test"));
}
private async Task&...
0
votes
0
answers
147
views
Async ConfigureAwait(false) Exception Handling-Long Running Processes [duplicate]
I have two long processes that are inside a Task.Run block that I want to run concurrently and capture any exceptions that may occur. I don't want to wait for these tasks to complete and I want to ...
0
votes
1
answer
604
views
WhenAll Task.Run Tasks Hang when Exceptions Occur
I have a minimal example of some async code that is exhibiting strange behavior. This is sandbox code, more geared at trying to understand async better --
private async Task ...
3
votes
2
answers
1k
views
Fail async method without throwing an exception
Suppose I have the following method, and the code that calls it:
public async Task<MyResult> PerformAction(string parameter)
{
if(parameter == "fail")
throw new Exception(&...
2
votes
1
answer
684
views
.NET Core Web API Handling Exceptions after a Response is already sent
I have a .NET Core 3.1 Web API that exposes access to some long-running operations. Say for example a client is requesting the API to perform some calculation that takes a while. API delegates that ...