From 94d11a63c3d023d5f215e462a8dc73caa8327b4b Mon Sep 17 00:00:00 2001 From: Raymond Chen Date: Wed, 3 Feb 2016 16:46:22 -0800 Subject: [PATCH] Windows 10 RTM Release - February 2016 Update --- README.md | 1 + .../cs/3-DeviceCapabilities.xaml.cs | 2 +- Samples/ExtendedExecution/README.md | 117 +++++++++++ .../cs/ExtendedExecution.csproj | 181 +++++++++++++++++ .../cs/ExtendedExecution.sln | 40 ++++ .../ExtendedExecution/cs/Package.appxmanifest | 43 ++++ .../cs/SampleConfiguration.cs | 64 ++++++ .../cs/Scenario1_UnspecifiedReason.xaml | 41 ++++ .../cs/Scenario1_UnspecifiedReason.xaml.cs | 142 +++++++++++++ .../cs/Scenario2_SavingDataReason.xaml | 36 ++++ .../cs/Scenario2_SavingDataReason.xaml.cs | 103 ++++++++++ .../cs/Scenario3_LocationTrackingReason.xaml | 41 ++++ .../Scenario3_LocationTrackingReason.xaml.cs | 188 ++++++++++++++++++ Samples/ExtendedExecution/cs/project.json | 16 ++ Samples/VideoPlayback/README.md | 2 +- Samples/WebAccountManagement/README.md | 9 +- Samples/WindowsAudioSession/README.md | 17 +- .../ControlPages/SemanticZoomPage.xaml | 2 +- 18 files changed, 1037 insertions(+), 8 deletions(-) create mode 100644 Samples/ExtendedExecution/README.md create mode 100644 Samples/ExtendedExecution/cs/ExtendedExecution.csproj create mode 100644 Samples/ExtendedExecution/cs/ExtendedExecution.sln create mode 100644 Samples/ExtendedExecution/cs/Package.appxmanifest create mode 100644 Samples/ExtendedExecution/cs/SampleConfiguration.cs create mode 100644 Samples/ExtendedExecution/cs/Scenario1_UnspecifiedReason.xaml create mode 100644 Samples/ExtendedExecution/cs/Scenario1_UnspecifiedReason.xaml.cs create mode 100644 Samples/ExtendedExecution/cs/Scenario2_SavingDataReason.xaml create mode 100644 Samples/ExtendedExecution/cs/Scenario2_SavingDataReason.xaml.cs create mode 100644 Samples/ExtendedExecution/cs/Scenario3_LocationTrackingReason.xaml create mode 100644 Samples/ExtendedExecution/cs/Scenario3_LocationTrackingReason.xaml.cs create mode 100644 Samples/ExtendedExecution/cs/project.json diff --git a/README.md b/README.md index 9222bd0578..9cb14e277f 100644 --- a/README.md +++ b/README.md @@ -414,6 +414,7 @@ For additional Windows samples, see [Windows on GitHub](http://microsoft.github. Association launching Background task + Extended execution diff --git a/Samples/BasicInput/cs/3-DeviceCapabilities.xaml.cs b/Samples/BasicInput/cs/3-DeviceCapabilities.xaml.cs index 597bd66085..d67813d861 100644 --- a/Samples/BasicInput/cs/3-DeviceCapabilities.xaml.cs +++ b/Samples/BasicInput/cs/3-DeviceCapabilities.xaml.cs @@ -35,7 +35,7 @@ public Scenario3() System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("Mouse present = " + mouseCapabilities.MousePresent.ToString() + "\n"); sb.Append("Number of buttons = " + mouseCapabilities.NumberOfButtons.ToString() + "\n"); - sb.Append("Vertical wheel present present = " + mouseCapabilities.VerticalWheelPresent.ToString() + "\n"); + sb.Append("Vertical wheel present = " + mouseCapabilities.VerticalWheelPresent.ToString() + "\n"); sb.Append("Horizontal wheel present = " + mouseCapabilities.HorizontalWheelPresent.ToString() + "\n"); sb.Append("Buttons swapped = " + mouseCapabilities.SwapButtons.ToString()); mouseText.Text = sb.ToString(); diff --git a/Samples/ExtendedExecution/README.md b/Samples/ExtendedExecution/README.md new file mode 100644 index 0000000000..b5b61015f5 --- /dev/null +++ b/Samples/ExtendedExecution/README.md @@ -0,0 +1,117 @@ + + +# Extended execution sample + +This sample shows you how to create extended execution sessions using the Windows Runtime extended execution API. + +**Note** The Universal Windows app samples require Visual Studio 2015 to build and Windows 10 to execute. + +An app requests an extended execution session when a task requires time to complete before the application is suspended or terminated. +Different types of extended execution can be requested during the Suspending state or the Resumed state of the application. + +This sample demonstrates the following: + +- Creating an extended execution session to extend suspending time and complete saving data. +- Creating an extended execution session to extend foreground time and continue location tracking. +- Creating an extended execution session to extend foreground time and continue an unspecified task. +- Handling a denied request for extended execution. +- Handling the revocation of an extended execution session. + +See **Deploying and running the sample** below for instructions on using the sample. + +## Related topics + +### Samples + +* [Background audio](/Samples/BackgroundAudio) +* [Geolocation](/Samples/Geolocation) + +### Other resources + +[Background Tasks and Extended Execution](https://msdn.microsoft.com/en-us/magazine/mt590969) + +[Launching, resuming, and background tasks](https://msdn.microsoft.com/en-us/library/windows/apps/xaml/mt227652.aspx) + +[Support your app with background tasks](https://msdn.microsoft.com/library/windows/apps/mt299103) + +### Reference + +[**Windows.ApplicationModel.ExtendedExecution**](https://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.extendedexecution.aspx) + +### Related technologies + +[**Windows.ApplicationModel.Background**](http://msdn.microsoft.com/library/windows/apps/br224847) + +## Operating system requirements + +**Client:** Windows 10 + +**Server:** Windows Server 2016 Technical Preview + +**Phone:** Windows 10 + +## Build the sample + +1. If you download the samples ZIP, be sure to unzip the entire archive, not just the folder with the sample you want to build. +2. Start Microsoft Visual Studio 2015 and select **File** \> **Open** \> **Project/Solution**. +3. Starting in the folder where you unzipped the samples, go to the Samples subfolder, then the subfolder for this specific sample, then the subfolder for your preferred language (C++, C#, or JavaScript). Double-click the Visual Studio 2015 Solution (.sln) file. +4. Press Ctrl+Shift+B, or select **Build** \> **Build Solution**. + +## Run the sample + +**Deploying the sample** + +1. Select **Build** \> **Deploy Solution**. + +**Deploying and running the sample** + +1. To debug the sample and then run it, press F5 or select **Debug** \> **Start Debugging**. To run the sample without debugging, press Ctrl+F5 or select**Debug** \> **Start Without Debugging**. +Since the system will not suspend an app that is being debugged, +some scenarios require you to run the sample without debugging. + +**Unspecified Extended Execution**: + +1. Run the sample without debugging and go to the **Unspecified Reason** scenario. +2. Click **Begin Extended Execution**. +3. Send the program to the background: + On Phone, switch to another app. + On PC, minimize the app. +4. The app continues to display toast notifications. +5. Bring the app back to the foreground to cause a revoke due to Resume. +6. Run the sample with debugging. +7. Repeat steps 2 through 4 above. +8. Use the Lifecycle events menu in the debugger to suspend the app. + This simulates a revoke due to SystemPolicy. + +**Saving Data Extended Execution**: + +1. Run the sample without debugging and go to the **Saving Data Reason** scenario. +2. Send the program to the background: + On Phone, switch to another app. + On PC, minimize the app. +3. The app displays toast notifications while the save operation proceeds, + demonstrating that the app was given a longer period of time to save data while suspending. + +**Location Tracking Extended Execution**: + +1. Run the sample without debugging and go to the **Location Tracking Reason** scenario. +2. Click **Begin Extended Execution**. +3. Send the program to the background: + On Phone, switch to another app. + On PC, minimize the app. +4. The app continues to report your location every 10 seconds. +5. Bring the app back to the foreground to cause a revoke due to Resume. +6. Run the sample with debugging. +7. Repeat steps 2 through 4 above. +8. Use the Lifecycle events menu in the debugger to suspend the app. + This simulates a revoke due to SystemPolicy. + +## Read more + +See the following topics for step-by-step information about using extended execution: + +- [Background Tasks and Extended Execution](https://msdn.microsoft.com/en-us/magazine/mt590969) + diff --git a/Samples/ExtendedExecution/cs/ExtendedExecution.csproj b/Samples/ExtendedExecution/cs/ExtendedExecution.csproj new file mode 100644 index 0000000000..c2a9cfb2c5 --- /dev/null +++ b/Samples/ExtendedExecution/cs/ExtendedExecution.csproj @@ -0,0 +1,181 @@ + + + + + Debug + x86 + {3DE0BD30-8F0D-4835-91C5-9EC6133B7B0F} + AppContainerExe + Properties + SDKTemplate + ExtendedExecution + en-US + UAP + 10.0.10240.0 + 10.0.10240.0 + 14 + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + true + bin\x86\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + x86 + false + prompt + true + + + bin\x86\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + x86 + false + prompt + true + true + + + true + bin\ARM\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + ARM + false + prompt + true + + + bin\ARM\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + ARM + false + prompt + true + true + + + true + bin\x64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + x64 + false + prompt + true + + + bin\x64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + x64 + false + prompt + true + true + + + + + + + + App.xaml.cs + App.xaml + + + MainPage.xaml.cs + MainPage.xaml + + + Properties\AssemblyInfo.cs + + + + + + + + + Designer + + + + + Assets\microsoft-sdk.png + + + Assets\smalltile-sdk.png + + + Assets\splash-sdk.png + + + Assets\squaretile-sdk.png + + + Assets\storelogo-sdk.png + + + Assets\tile-sdk.png + + + Assets\windows-sdk.png + + + Properties\Default.rd.xml + + + + + App.xaml + MSBuild:Compile + Designer + + + MainPage.xaml + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Styles\Styles.xaml + Designer + MSBuild:Compile + + + + 14.0 + + + + \ No newline at end of file diff --git a/Samples/ExtendedExecution/cs/ExtendedExecution.sln b/Samples/ExtendedExecution/cs/ExtendedExecution.sln new file mode 100644 index 0000000000..427869a37d --- /dev/null +++ b/Samples/ExtendedExecution/cs/ExtendedExecution.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExtendedExecution", "ExtendedExecution.csproj", "{3DE0BD30-8F0D-4835-91C5-9EC6133B7B0F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3DE0BD30-8F0D-4835-91C5-9EC6133B7B0F}.Debug|ARM.ActiveCfg = Debug|ARM + {3DE0BD30-8F0D-4835-91C5-9EC6133B7B0F}.Debug|ARM.Build.0 = Debug|ARM + {3DE0BD30-8F0D-4835-91C5-9EC6133B7B0F}.Debug|ARM.Deploy.0 = Debug|ARM + {3DE0BD30-8F0D-4835-91C5-9EC6133B7B0F}.Debug|x64.ActiveCfg = Debug|x64 + {3DE0BD30-8F0D-4835-91C5-9EC6133B7B0F}.Debug|x64.Build.0 = Debug|x64 + {3DE0BD30-8F0D-4835-91C5-9EC6133B7B0F}.Debug|x64.Deploy.0 = Debug|x64 + {3DE0BD30-8F0D-4835-91C5-9EC6133B7B0F}.Debug|x86.ActiveCfg = Debug|x86 + {3DE0BD30-8F0D-4835-91C5-9EC6133B7B0F}.Debug|x86.Build.0 = Debug|x86 + {3DE0BD30-8F0D-4835-91C5-9EC6133B7B0F}.Debug|x86.Deploy.0 = Debug|x86 + {3DE0BD30-8F0D-4835-91C5-9EC6133B7B0F}.Release|ARM.ActiveCfg = Release|ARM + {3DE0BD30-8F0D-4835-91C5-9EC6133B7B0F}.Release|ARM.Build.0 = Release|ARM + {3DE0BD30-8F0D-4835-91C5-9EC6133B7B0F}.Release|ARM.Deploy.0 = Release|ARM + {3DE0BD30-8F0D-4835-91C5-9EC6133B7B0F}.Release|x64.ActiveCfg = Release|x64 + {3DE0BD30-8F0D-4835-91C5-9EC6133B7B0F}.Release|x64.Build.0 = Release|x64 + {3DE0BD30-8F0D-4835-91C5-9EC6133B7B0F}.Release|x64.Deploy.0 = Release|x64 + {3DE0BD30-8F0D-4835-91C5-9EC6133B7B0F}.Release|x86.ActiveCfg = Release|x86 + {3DE0BD30-8F0D-4835-91C5-9EC6133B7B0F}.Release|x86.Build.0 = Release|x86 + {3DE0BD30-8F0D-4835-91C5-9EC6133B7B0F}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/ExtendedExecution/cs/Package.appxmanifest b/Samples/ExtendedExecution/cs/Package.appxmanifest new file mode 100644 index 0000000000..ee9d746236 --- /dev/null +++ b/Samples/ExtendedExecution/cs/Package.appxmanifest @@ -0,0 +1,43 @@ + + + + + + Extended Execution C# Sample + Microsoft Corporation + Assets\StoreLogo-sdk.png + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/ExtendedExecution/cs/SampleConfiguration.cs b/Samples/ExtendedExecution/cs/SampleConfiguration.cs new file mode 100644 index 0000000000..0118d44c5f --- /dev/null +++ b/Samples/ExtendedExecution/cs/SampleConfiguration.cs @@ -0,0 +1,64 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +using System; +using System.Collections.Generic; +using Windows.Data.Xml.Dom; +using Windows.UI.Notifications; +using Windows.UI.Xaml.Controls; + + +namespace SDKTemplate +{ + public partial class MainPage : Page + { + public const string FEATURE_NAME = "Extended Execution"; + + List scenarios = new List + { + new Scenario() { Title="Unspecified Reason", ClassType=typeof(UnspecifiedReason)}, + new Scenario() { Title="Saving Data Reason", ClassType=typeof(SavingDataReason)}, + new Scenario() { Title="Location Tracking Reason", ClassType=typeof(LocationTrackingReason)}, + }; + + public static ToastNotification DisplayToast(string content) + { + string xml = $@" + + + Extended Execution + + + "; + + XmlDocument doc = new XmlDocument(); + doc.LoadXml(xml); + + var binding = doc.SelectSingleNode("//binding"); + + var el = doc.CreateElement("text"); + el.InnerText = content; + binding.AppendChild(el); //Add content to notification + + var toast = new ToastNotification(doc); + + ToastNotificationManager.CreateToastNotifier().Show(toast); //Show the toast + + return toast; + } + } + + public class Scenario + { + public string Title { get; set; } + public Type ClassType { get; set; } + } +} \ No newline at end of file diff --git a/Samples/ExtendedExecution/cs/Scenario1_UnspecifiedReason.xaml b/Samples/ExtendedExecution/cs/Scenario1_UnspecifiedReason.xaml new file mode 100644 index 0000000000..fd8c3cf214 --- /dev/null +++ b/Samples/ExtendedExecution/cs/Scenario1_UnspecifiedReason.xaml @@ -0,0 +1,41 @@ + + + + + + + + + + Requests for extended execution using the "Unspecified" reason + are allowed only during the Resumed lifecycle stage. + The app raises a toast every ten seconds to demonstrate that it is still running. + +