2
votes
3answers
52 views

Regarding asynchronous Task, why is a Wait() required to catch OperationCanceledException?

I'm following the example code here to learn about asynchronous tasks. I've modified the code to write some output of the task's work vs. the main work. The output will look like this: I noticed ...
2
votes
2answers
52 views

TaskEx.WhenAll and Exceptions

I'm constrained to using the .NET 4.0 framework and Async CTP Extensions to do something like the following: var dataTasks = _tasks.Select(t => t.GetData(keys)); var results = ...
2
votes
1answer
62 views

Unhandled exceptions when using TPL while OnlyOnFaulted is presented

This is a sample code from a "C# 5.0 in a Nutshell" TaskCreationOptions atp = TaskCreationOptions.AttachedToParent; Task.Factory.StartNew (() => { Task.Factory.StartNew (() => { throw null; ...
0
votes
1answer
96 views

Does the Recommended Task Exception-Handling Code Synchronize the Task?

It looks like the pattern on MSDN for handling exceptions raised in a Task synchronizes the code. Here is the code from the MSDN page: var task1 = Task.Factory.StartNew(() => { throw new ...
0
votes
2answers
97 views

How to get an exception raised from a long running background Task without having main thread to wait

I want to perform some long running operation (e.g. listening to some event raised by OS) on the background thread. Most of the times, operation will run continuously without any problem. But in ...
2
votes
0answers
50 views

Is there a way to inject additional functionality before or after an Task action like AOP [closed]

Is it possible to use Exception Handling Application block for fire and forget kind of Tasks using TPL? If yes how? Update: My current application UI is a mix of Winforms and WPF forms. It has ...
0
votes
1answer
153 views

Handle exception thrown somewhere in a task continuation

What is the best way to handle exceptions thrown somewhere in a task continuation? For example, I have a simple task continuation below (updateMessages -> updateInterface) but in reality this could ...
1
vote
2answers
148 views

How to translate exceptions from Tasks returned by asynchronous ASP.NET Web API methods?

When Tasks returned by (asynchronous) ASP.NET Web API controller methods throw exceptions, I would like to translate known exceptions to HttpResponseException. Is there some way to intercept these ...
0
votes
1answer
96 views

Exception continuation doesn't work with completion continuation

I have this simple TPL code: var t = Task.Factory.StartNew(() => { throw null; }) .ContinueWith((ant) => { Console.WriteLine("Success"); }, ...
0
votes
2answers
305 views

status code on async webresponse task

I want to hit a plethora (100k+) of JSON files as rapidly as possible, serialize them, and store the HTTP response status code of the request (whether it succeeded or failed). (I am using ...
0
votes
2answers
420 views

Elegantly handle task cancellation

When using tasks for large/long running workloads that I need to be able to cancel I often use a template similar to this for the action the task executes: public void DoWork(CancellationToken ...
3
votes
1answer
130 views

What is the recommended way to handle TaskScheduler.UnobservedTaskException in GUI apps?

For robustness I want to add a handler for TaskScheduler.UnobservedTaskException. The handler does log Exception(s) inform the user and shutdown the app. Does the following implementation make sense? ...
0
votes
1answer
173 views

How to handle Task Exceptions in GUI?

What is the recommended way to handle errors when using Tasks to unblock the UI and using Aync/Await is not an option? I typically want to handle expected errors by updating the UI and handle ...
1
vote
1answer
605 views

UnobservedTaskException being throw but it is handled by a TaskScheduler.UnobservedTaskException handler and a continuations OnlyOnFaulted handler [duplicate]

Possible Duplicate: How to handle all unhandled exceptions when using Task Parallel Library? @Buu Nguyen Hi, solution is based on your idea Someone put it as possible duplicate, ...
0
votes
0answers
79 views

Task getting canceled when it shouldn't

I am using the c# TaskScheduler to start some tasks and it is throwing a TaskCanceledException somehow. I stepped all the way through the function the task calls and it completes fine and no ...
2
votes
1answer
465 views

Exception thrown in Task Thread, not caught by UnobservedTaskException

I'm having trouble understanding how Exceptions are handled in TPL. The following code should illustrate my problem. using System; using System.Collections.Generic; using System.Net; using ...
2
votes
3answers
867 views

Retry a task multiple times based on user input in case of an exception in task

All the service calls in my application are implemented as tasks.When ever a task is faulted ,I need to present the user with a dialog box to retry the last operation failed.If the user chooses retry ...
0
votes
0answers
118 views

Understanding catching exceptions and doing continuations in multi-threaded code

I'm checking a bit of work I'm doing and thought I'd get a few more eyes on it. I have code in production that's giving us trouble. It's using multi-threading and I'm relatively new to that area. I ...
1
vote
2answers
330 views

Task Parallel Library and exception

I have an application that are executing 4 different jobs parallel. I use the parallel task library. The code looks like this: while (true) { var fetch = new FetcherHandler(); ...
2
votes
1answer
305 views

Task Asynchronous Pattern and error/exception/cancellation handling

I often have applications where the top level function works something like public Result5 ProcessAll() { var result1 = Process1(); var result2 = Process2(); var result3 = ...
0
votes
0answers
101 views

Task Exceptions C# [closed]

i'm working in a c# windows application with vs2010 and a local database.In one of my forms, I'm using a bindingNavigator and i use the code below in order to move to the next record. The problem is ...
5
votes
1answer
692 views

handling exception in Tpl

I have read a lot on how to handle exceptions in TPL but don't really understand. Lets take this example code: var task1 = new Task(() => { throw new Exception("Throw 1"); }); var task2 = ...
3
votes
2answers
952 views

TPL and Exception Handling

All, there are many question on the above topic but I believe this is sufficiently different to warrant a new question. I have the following Task and a continuation to deal with a variety of task ...
1
vote
1answer
344 views

Handling unobserved Task exceptions

I know that I can handle the UnobservedTaskException to prevent any unobserved exceptions from terminating my application when the finalizer runs on the object. However, I'm not sure where or when I ...
0
votes
1answer
159 views

Translating exceptions for Task<T> with Task Parallel Library a la await

I'm trying to do the equivalent of the dollowing C# 5 pseudocode:- async Task<int> CallAndTranslate() { try { return await client.CallAsync(); } catch(FaultException ex) { ...
2
votes
1answer
321 views

Pattern for implementing sync methods in terms of non-parallel Task (Translating/Unwrapping AggregateExceptions)

I have an Async method returning a Task. I also wish to offer a synchronous equivalent, but I don't want consumers of it to have to go unpacking AggregateExceptions. Now I understand that the whole ...
0
votes
1answer
245 views

Translating exceptions for void Tasks with Task Parallel Library a la await

I need to translate an exception emanating from a Task<T> in the same manner that doing the following would for normal synchronous code: try { client.Call(); } catch(FaultException ex) { ...
2
votes
3answers
1k views

Handling exception with TPL without Wait()

I have an application with Start and Stop buttons, and a thread that is ran in the background after pressing Start. I use MVC and TPL for that. How can I handle exception in the TPL, as I never ...
7
votes
1answer
845 views

How can I wait on tasks without throwing TaskCanceledExceptions?

I have a method that creates some Tasks, and then waits on them with WaitAll before returning. The problem is, if those tasks got canceled, then WaitAll throws an AggregateException containing lots of ...
2
votes
1answer
300 views

Problems with windows service, blockingcollection, and Multithreading

My scenario: Windows Service .NET 4 I poll a database for entities. When new entities come in they are added to a BlockingCollection. In the service's OnStart I create a System.Threading.Tasks.Task ...

1 2
15 30 50 per page