Question: I have the following code

```
Task load = Task.Factory.StartNew(() => 
{
    Threading.Thread.Sleep(5000);
    throw new Exception("bad error");                
});

try{
    load.Wait();
}catch(AggregateException aex){
    MessageBox.Show("Error Caught!");
}

```

Here as you can see, I create a task and throw an exception.
The exception is then caught on the UI thread. But with this this set up, the UI will be un responsive. 

**What is the work around for this to make the UI responsive and catch the Exception?**

Answer: 
There is a couple of ways to handle this. 

You could use [`ContinueWith`](http://msdn.microsoft.com/en-us/library/dd321576.aspx) and check there, or you could just hook into the [global task exception handler TaskScheduler.UnobservedTaskException)](http://msdn.microsoft.com/en-us/library/system.threading.tasks.taskscheduler.unobservedtaskexception.aspx). (details to come)

ContinueWith for exception handling only:

```
load.ContinueWith(previousTask => 
    {
        //exception message here
    }, TaskContinuationOptions.OnlyOnFaulted);

```

or for with a normal try catch:

```
load.ContinueWith(previousTask => 
    {
        try
        {
            previousTask.Result
        }
        catch(Exception ex){//message here}
    });

```
You'll want to add a continuation to the task, rather than using `Wait` or any other means of blocking on the task.

```
load.ContinueWith(t => MessageBox.Show(t.Exception.Message)
    , TaskContinuationOptions.OnlyOnFaulted);

```