Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions Sample/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Storage;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
Expand Down Expand Up @@ -58,12 +62,8 @@ private async void App_UnhandledException(object sender, Windows.UI.Xaml.Unhandl
/// search results, and so forth.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs args)
protected override async void OnLaunched(LaunchActivatedEventArgs args)
{
// Start custom code
RegisterExceptionHandlingSynchronizationContext();
// End custom code

Frame rootFrame = Window.Current.Content as Frame;

// Do not repeat app initialization when the Window already has content,
Expand All @@ -80,6 +80,10 @@ protected override void OnLaunched(LaunchActivatedEventArgs args)

// Place the frame in the current Window
Window.Current.Content = rootFrame;

ExceptionHandlingSynchronizationContext
.RegisterForFrame(rootFrame)
.UnhandledException += SynchronizationContext_UnhandledException;
}

if (rootFrame.Content == null)
Expand All @@ -94,6 +98,8 @@ protected override void OnLaunched(LaunchActivatedEventArgs args)
}
// Ensure the current window is active
Window.Current.Activate();

await Test.LaunchAsync();
}

protected override void OnActivated(IActivatedEventArgs args)
Expand All @@ -118,4 +124,17 @@ private void OnSuspending(object sender, SuspendingEventArgs e)
deferral.Complete();
}
}

internal class Test
{
public static async Task LaunchAsync()
{
Debug.WriteLine("Before CreateFolderAsync: {0}", SynchronizationContext.Current);
await ApplicationData.Current.LocalFolder.CreateFolderAsync("cache", CreationCollisionOption.OpenIfExists);
Debug.WriteLine("After CreateFolderAsync:{0}", SynchronizationContext.Current);

await Task.Yield();
Debug.WriteLine("After Task.Yield: {0}", SynchronizationContext.Current);
}
}
}