summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WP8
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.WP8')
-rw-r--r--Xamarin.Forms.Platform.WP8/TaskExtensions.cs33
-rw-r--r--Xamarin.Forms.Platform.WP8/WP8PlatformServices.cs2
-rw-r--r--Xamarin.Forms.Platform.WP8/Xamarin.Forms.Platform.WP8.csproj3
3 files changed, 36 insertions, 2 deletions
diff --git a/Xamarin.Forms.Platform.WP8/TaskExtensions.cs b/Xamarin.Forms.Platform.WP8/TaskExtensions.cs
new file mode 100644
index 00000000..51f275d7
--- /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<T>(this IAsyncOperation<T> 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 c20071f4..4d49315e 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<bool> callback)
diff --git a/Xamarin.Forms.Platform.WP8/Xamarin.Forms.Platform.WP8.csproj b/Xamarin.Forms.Platform.WP8/Xamarin.Forms.Platform.WP8.csproj
index d2e99c8a..c615ba4b 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 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
- <NoWarn>4014;0618;0219</NoWarn>
+ <NoWarn>0618;0219</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -202,6 +202,7 @@
<DependentUpon>TableView.xaml</DependentUpon>
</Compile>
<Compile Include="TableViewRenderer.cs" />
+ <Compile Include="TaskExtensions.cs" />
<Compile Include="TextAlignmentToHorizontalAlignmentConverter.cs" />
<Compile Include="TextCellRenderer.cs" />
<Compile Include="TimePickerRenderer.cs" />