fix(backgroundTask): create winrt component project to create background tasks in mpm

This commit is contained in:
Odonno 2017-02-25 19:05:47 +01:00
Родитель a8685a7d3f
Коммит b408e13852
9 изменённых файлов: 276 добавлений и 3 удалений

Просмотреть файл

@ -829,6 +829,10 @@
</Page>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.Toolkit.Uwp.Samples.BackgroundTasks\Microsoft.Toolkit.Uwp.Samples.BackgroundTasks.csproj">
<Project>{1ae2cb5c-58a0-4f12-8e6f-2cd4aaadb34c}</Project>
<Name>Microsoft.Toolkit.Uwp.Samples.BackgroundTasks</Name>
</ProjectReference>
<ProjectReference Include="..\Microsoft.Toolkit.Uwp.Services\Microsoft.Toolkit.Uwp.Services.csproj">
<Project>{7189a42d-6f1a-4fa3-8e00-e2c14fdf167a}</Project>
<Name>Microsoft.Toolkit.Uwp.Services</Name>

Просмотреть файл

@ -32,6 +32,11 @@
<uap:DisplayName>UWP Community Toolkit</uap:DisplayName>
</uap:Protocol>
</uap:Extension>
<Extension Category="windows.backgroundTasks" EntryPoint="Microsoft.Toolkit.Uwp.Samples.BackgroundTasks.TestBackgroundTask">
<BackgroundTasks>
<Task Type="timer" />
</BackgroundTasks>
</Extension>
</Extensions>
</Application>
</Applications>

Просмотреть файл

@ -13,7 +13,7 @@ await BackgroundExecutionManager.RequestAccessAsync();
BackgroundTaskHelper.Register(testBackgroundTaskName, new TimeTrigger(15, false));
// Register (Multi Process) w/ Conditions.
BackgroundTaskHelper.Register(nameof(TestBackgroundTask), "Microsoft.Toolkit.Uwp.SampleApp.SamplePages", new TimeTrigger(15, false), false, true, new SystemCondition(SystemConditionType.InternetAvailable));
BackgroundTaskHelper.Register(nameof(TestBackgroundTask), "Microsoft.Toolkit.Uwp.Samples.BackgroundTasks.TestBackgroundTask", new TimeTrigger(15, false), false, true, new SystemCondition(SystemConditionType.InternetAvailable));
//Unregister
BackgroundTaskHelper.Unregister(testBackgroundTaskName);

Просмотреть файл

@ -47,8 +47,8 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
// Check for background access.
await BackgroundExecutionManager.RequestAccessAsync();
// If registering Multi-Process Background task
BackgroundTaskHelper.Register(nameof(TestBackgroundTask), "Microsoft.Toolkit.Uwp.SampleApp.SamplePages", new TimeTrigger(15, false), false, true, new SystemCondition(SystemConditionType.InternetAvailable));
// Registering Multi-Process Background task
BackgroundTaskHelper.Register(nameof(TestBackgroundTask), "Microsoft.Toolkit.Uwp.Samples.BackgroundTasks.TestBackgroundTask", new TimeTrigger(15, false), false, true, new SystemCondition(SystemConditionType.InternetAvailable));
StatusMessage.Text = "Background Task registered (MPM)";
}

Просмотреть файл

@ -0,0 +1,131 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}</ProjectGuid>
<OutputType>winmdobj</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Toolkit.Uwp.Samples.BackgroundTasks</RootNamespace>
<AssemblyName>Microsoft.Toolkit.Uwp.Samples.BackgroundTasks</AssemblyName>
<DefaultLanguage>fr-FR</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.14393.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10586.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<AllowCrossPlatformRetargeting>false</AllowCrossPlatformRetargeting>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestBackgroundTask.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Notifications\Microsoft.Toolkit.Uwp.Notifications.UWP\Microsoft.Toolkit.Uwp.Notifications.UWP.csproj">
<Project>{fb381278-f4ad-4703-a12a-c43ee0b231bd}</Project>
<Name>Microsoft.Toolkit.Uwp.Notifications.UWP</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Просмотреть файл

@ -0,0 +1,40 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Microsoft.Toolkit.Uwp.Samples.BackgroundTasks")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Microsoft.Toolkit.Uwp.Samples.BackgroundTasks")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: ComVisible(false)]

Просмотреть файл

@ -0,0 +1,47 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using Microsoft.Toolkit.Uwp.Notifications;
using Windows.ApplicationModel.Background;
using Windows.UI.Notifications;
namespace Microsoft.Toolkit.Uwp.Samples.BackgroundTasks
{
public sealed class TestBackgroundTask : IBackgroundTask
{
public void Run(IBackgroundTaskInstance taskInstance)
{
// Create content of the toast notification
var toastContent = new ToastContent()
{
Scenario = ToastScenario.Default,
Visual = new ToastVisual
{
BindingGeneric = new ToastBindingGeneric
{
Children =
{
new AdaptiveText
{
Text = "New toast notification (BackgroundTaskHelper)."
}
}
}
}
};
// Create & show toast notification
var toastNotification = new ToastNotification(toastContent.GetXml());
ToastNotificationManager.CreateToastNotifier().Show(toastNotification);
}
}
}

Просмотреть файл

@ -0,0 +1,16 @@
{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2"
},
"frameworks": {
"uap10.0": {}
},
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
}
}

Просмотреть файл

@ -45,6 +45,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests.Notifications.Win
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarkdownTextBlockUnitTests", "UnitTests\UnitTests.MarkdownTextBlock\MarkdownTextBlockUnitTests.csproj", "{519A9FE1-E530-4764-804E-A41F0D68D6B9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{9AD30620-667D-433C-9961-8D885EE7B762}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Toolkit.Uwp.Samples.BackgroundTasks", "Microsoft.Toolkit.Uwp.Samples.BackgroundTasks\Microsoft.Toolkit.Uwp.Samples.BackgroundTasks.csproj", "{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Notifications\Microsoft.Toolkit.Uwp.Notifications.Shared\Microsoft.Toolkit.Uwp.Notifications.Shared.projitems*{52f9acf2-55e7-4415-92bd-902cf85ce3da}*SharedItemsImports = 4
@ -456,6 +460,30 @@ Global
{519A9FE1-E530-4764-804E-A41F0D68D6B9}.Release|x86.ActiveCfg = Release|x86
{519A9FE1-E530-4764-804E-A41F0D68D6B9}.Release|x86.Build.0 = Release|x86
{519A9FE1-E530-4764-804E-A41F0D68D6B9}.Release|x86.Deploy.0 = Release|x86
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Debug|ARM.ActiveCfg = Debug|ARM
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Debug|ARM.Build.0 = Debug|ARM
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Debug|x64.ActiveCfg = Debug|x64
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Debug|x64.Build.0 = Debug|x64
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Debug|x86.ActiveCfg = Debug|x86
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Debug|x86.Build.0 = Debug|x86
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Publish|Any CPU.ActiveCfg = Release|Any CPU
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Publish|Any CPU.Build.0 = Release|Any CPU
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Publish|ARM.ActiveCfg = Release|ARM
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Publish|ARM.Build.0 = Release|ARM
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Publish|x64.ActiveCfg = Release|x64
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Publish|x64.Build.0 = Release|x64
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Publish|x86.ActiveCfg = Release|x86
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Publish|x86.Build.0 = Release|x86
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Release|Any CPU.Build.0 = Release|Any CPU
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Release|ARM.ActiveCfg = Release|ARM
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Release|ARM.Build.0 = Release|ARM
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Release|x64.ActiveCfg = Release|x64
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Release|x64.Build.0 = Release|x64
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Release|x86.ActiveCfg = Release|x86
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -464,6 +492,7 @@ Global
{A139968E-AD78-4E8C-93B8-9A5523BCAC89} = {B30036C4-D514-4E5B-A323-587A061772CE}
{3DD8AA7C-3569-4E51-992F-0C2257E8878E} = {F1AFFFA7-28FE-4770-BA48-10D76F3E59BC}
{B24A296C-B3EB-4E06-A64E-74AC2D1ACC91} = {F1AFFFA7-28FE-4770-BA48-10D76F3E59BC}
{719C43C6-8753-4395-ADAA-2FCC70F76BF3} = {9AD30620-667D-433C-9961-8D885EE7B762}
{E9FAABFB-D726-42C1-83C1-CB46A29FEA81} = {F1AFFFA7-28FE-4770-BA48-10D76F3E59BC}
{8BACD7A9-B205-4ADF-BDA9-763B30A66576} = {AC34EA36-5E97-4158-B7A0-3D4BBF1BAA54}
{52F9ACF2-55E7-4415-92BD-902CF85CE3DA} = {AC34EA36-5E97-4158-B7A0-3D4BBF1BAA54}
@ -476,5 +505,6 @@ Global
{BAB1CAF4-C400-4A7F-A987-C576DE63CFFD} = {9333C63A-F64F-4797-82B3-017422668A5D}
{EFA96B3C-857E-4659-B942-6BEF7719F4CA} = {9333C63A-F64F-4797-82B3-017422668A5D}
{519A9FE1-E530-4764-804E-A41F0D68D6B9} = {B30036C4-D514-4E5B-A323-587A061772CE}
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C} = {9AD30620-667D-433C-9961-8D885EE7B762}
EndGlobalSection
EndGlobal