Mercurial > silverbladetech
comparison MetroWpf/MetroWpf.Framework/Extensions/TaskExtensions.cs @ 15:060f02cd4591
Initial commit, pre airport work
author | stevenh7776 stevenhollidge@hotmail.com |
---|---|
date | Mon, 12 Mar 2012 23:05:21 +0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
14:741981715d94 | 15:060f02cd4591 |
---|---|
1 using System; | |
2 using System.Threading.Tasks; | |
3 | |
4 namespace MetroWpf.Framework.Extensions | |
5 { | |
6 public static class TaskExtensions | |
7 { | |
8 public static void PropagateExceptions(this Task task) | |
9 { | |
10 if (task == null) | |
11 throw new ArgumentNullException("task"); | |
12 if (!task.IsCompleted) | |
13 throw new InvalidOperationException("The task has not completed yet."); | |
14 | |
15 if (task.IsFaulted) | |
16 task.Wait(); | |
17 } | |
18 | |
19 public static string GetErrorMessage(this AggregateException ex) | |
20 { | |
21 return ex.Flatten().InnerException.Message; | |
22 } | |
23 } | |
24 } |