diff --git a/Xamarin.Forms.Platform.WP8/TaskExtensions.cs b/Xamarin.Forms.Platform.WP8/TaskExtensions.cs new file mode 100644 index 000000000..51f275d73 --- /dev/null +++ b/Xamarin.Forms.Platform.WP8/TaskExtensions.cs @@ -0,0 +1,33 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Windows.Foundation; + +namespace Xamarin.Forms +{ + internal static class TaskExtensions + { + public static void WatchForError(this IAsyncAction self) + { + self.AsTask().WatchForError(); + } + + public static void WatchForError(this IAsyncOperation self) + { + self.AsTask().WatchForError(); + } + + public static void WatchForError(this Task self) + { + SynchronizationContext context = SynchronizationContext.Current; + if (context == null) + return; + + self.ContinueWith(t => { + Exception exception = t.Exception.InnerExceptions.Count > 1 ? t.Exception : t.Exception.InnerException; + + context.Post(e => { throw (Exception)e; }, exception); + }, CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted, TaskScheduler.Default); + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Platform.WP8/WP8PlatformServices.cs b/Xamarin.Forms.Platform.WP8/WP8PlatformServices.cs index c20071f41..4d49315e6 100644 --- a/Xamarin.Forms.Platform.WP8/WP8PlatformServices.cs +++ b/Xamarin.Forms.Platform.WP8/WP8PlatformServices.cs @@ -134,7 +134,7 @@ namespace Xamarin.Forms public void OpenUriAction(Uri uri) { - Launcher.LaunchUriAsync(uri); + Launcher.LaunchUriAsync(uri).WatchForError(); } public void StartTimer(TimeSpan interval, Func callback) diff --git a/Xamarin.Forms.Platform.WP8/Xamarin.Forms.Platform.WP8.csproj b/Xamarin.Forms.Platform.WP8/Xamarin.Forms.Platform.WP8.csproj index d2e99c8ae..c615ba4ba 100644 --- a/Xamarin.Forms.Platform.WP8/Xamarin.Forms.Platform.WP8.csproj +++ b/Xamarin.Forms.Platform.WP8/Xamarin.Forms.Platform.WP8.csproj @@ -32,7 +32,7 @@ prompt 4 true - 4014;0618;0219 + 0618;0219 pdbonly @@ -202,6 +202,7 @@ TableView.xaml +