Skip to content

Commit 9e6b0f8

Browse files
authored
Merge pull request #601 from Code-ScottLe/dev
Add back in documentation for background task helper
2 parents 891ed22 + 752fb7c commit 9e6b0f8

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Background Task Helper
2+
3+
The **Background Task Helper** helps users interacting with background tasks in an easier manner.
4+
5+
## Example
6+
7+
```csharp
8+
9+
// Be sure to include the using at the top of the file:
10+
//using Microsoft.Toolkit.Uwp;
11+
//using Windows.ApplicationModel.Background;
12+
13+
// Register a normal, seperate process, background task
14+
BackgroundTaskRegistration registered = BackgroundTaskHelper.Register("TaskName","TaskEntryPoint", new TimeTrigger(15, true));
15+
16+
// This can also be written using the overload of Register with Type parameter.
17+
BackgroundTaskRegistration registered = BackgroundTaskHelper.Register(typeof(BackgroundTaskClass), new TimeTrigger(15, true));
18+
19+
// With condition
20+
BackgroundTaskRegistration registered =
21+
BackgroundTaskHelper.Register(typeof(BackgroundTaskClass),
22+
new TimeTrigger(15, true),
23+
false, true,
24+
new SystemCondition(SystemConditionType.InternetAvailable));
25+
26+
// 2 or more conditions
27+
BackgroundTaskRegistration registered =
28+
BackgroundTaskHelper.Register(typeof(BackgroundTaskClass),
29+
new TimeTrigger(15, true),
30+
false, true,
31+
new SystemCondition(SystemConditionType.InternetAvailable),
32+
new SystemCondition(SystemConditionType.UserPresent));
33+
34+
// Register a single process background task (Anniversary Update and later ONLY)
35+
BackgroundTaskRegistration registered = BackgroundTaskHelper.Register("TaskName", new TimeTrigger(15, true))
36+
37+
```
38+
39+
You can find more examples in our [unit tests](https://github.com/Microsoft/UWPCommunityToolkit/blob/master/UnitTests/Helpers/Test_BackgroundTaskHelper.cs)
40+
41+
## Requirements (Windows 10 Device Family)
42+
43+
| [Device family](http://go.microsoft.com/fwlink/p/?LinkID=526370) | Universal, 10.0.10586.0 or higher |
44+
| --- | --- |
45+
| Namespace | Microsoft.Toolkit.Uwp |
46+
47+
## API
48+
49+
* [Background Task source code](https://github.com/Microsoft/UWPCommunityToolkit/blob/master/Microsoft.Toolkit.Uwp/Helpers/BackgroundTaskHelper.cs)
50+

0 commit comments

Comments
 (0)