Linked Questions
33 questions linked to/from TAP global exception handler
0 votes
1 answer
248 views
Windows Store unhandled exceptions on TP threads don't crash the app [duplicate]
I have an async method that is throwing. This has no impact on my app, I see the exception in the debugger output window. I can turn on first chance exceptions and have the VS debugger catch it in ...
212 votes
8 answers
86k views
Suppressing "warning CS4014: Because this call is not awaited, execution of the current method continues..."
This is not a duplicate of "How to safely call an async method in C# without await". How do I nicely suppress the following warning? warning CS4014: Because this call is not awaited, execution of ...
113 votes
4 answers
51k views
Any difference between "await Task.Run(); return;" and "return Task.Run()"? [duplicate]
Is there any conceptual difference between the following two pieces of code: async Task TestAsync() { await Task.Run(() => DoSomeWork()); } and Task TestAsync() { return Task.Run(() =&...
22 votes
5 answers
18k views
What is the async/await equivalent of a ThreadPool server?
I am working on a tcp server that looks something like this using synchronous apis and the thread pool: TcpListener listener; void Serve(){ while(true){ var client = listener.AcceptTcpClient(); ...
44 votes
3 answers
15k views
What happens if I don't await a task?
Consider this example: var task = DoSomething() bool ready = await DoSomethingElse(); if (!ready) return null; var value = await DoThirdThing(); // depends on DoSomethingElse return value + await ...
27 votes
4 answers
20k views
"await Task.Yield()" and its alternatives
If I need to postpone code execution until after a future iteration of the UI thread message loop, I could do so something like this: await Task.Factory.StartNew( () => { MessageBox....
18 votes
1 answer
10k views
xUnit Async Test Not Working Properly
We have been using xUnit Framework in our project as test framework since the begining. Currently there are 2200+ unit tests in project and everything seems fine. But yesterday i decided to run unit ...
22 votes
2 answers
11k views
Unnecessary async/await when await is last?
I've been dealing quite a lot with async await lately (read every possible article including Stephen's and Jon's last 2 chapters) , but I have come to conclusion and I don't know if it's 100% correct. ...
18 votes
3 answers
16k views
Unexpected unhandledRejection event for promise which rejection does get handled
Updated, I've now tried explaining the behavior I'm seeing, but it'd still be great to have an answer from a credible source about the unhandledRejection behavor. I've also started a discussion thread ...
8 votes
3 answers
3k views
Why doesn't this exception get thrown?
I use a set of tasks at times, and in order to make sure they are all awaited I use this approach: public async Task ReleaseAsync(params Task[] TaskArray) { var tasks = new HashSet<Task>(...
16 votes
3 answers
5k views
Task sequencing and re-entracy
I've got the following scenario, which I think might be quite common: There is a task (a UI command handler) which can complete either synchronously or asynchronously. Commands may arrive faster than ...
7 votes
3 answers
4k views
system.threading.task - why does TaskScheduler.UnobservedTaskException event not occur? Can I fix this?
A common problem I've seen has been managing unhandled exceptions inside of tasks. They don't cause a crash, they happen silently, and I can't even get an event to trigger when the task fails! I've ...
4 votes
1 answer
8k views
The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))
In my windows phone 8.1 application I have a singleton service DataService which should once in a while be downloading some data. Meanwhile on UI I should be displaying the amount of data received. ...
10 votes
2 answers
4k views
AppDomain UnhandledException
I am working on a C# project and want to make use of the UnhandledException event to catch any exceptions I may have missed in my project (hoping there won't be any but to be on the same side). I ...
10 votes
2 answers
2k views
Throwing immediately from async method
The normal behavior for exceptions thrown from async Task methods is to stay dormant until they get observed later, or until the task gets garbage-collected. I can think of cases where I may want to ...