Skip to content

Commit c7b1c63

Browse files
Merge pull request #6611 from MicrosoftDocs/jken/fix-568630-background-tasks-gaps
Fix background tasks discoverability and WPF guidance gaps
2 parents 5ee9c5c + c8ebafb commit c7b1c63

5 files changed

Lines changed: 34 additions & 3 deletions

File tree

.openpublishing.redirection.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11420,7 +11420,7 @@
1142011420
"redirect_url": "/windows/apps/develop/accessibility",
1142111421
"redirect_document_id": false
1142211422
},
11423-
{
11423+
{
1142411424
"source_path": "hub/apps/package-and-deploy/choose-packaging-model.md",
1142511425
"redirect_url": "/windows/apps/package-and-deploy/packaging/",
1142611426
"redirect_document_id": false
@@ -11524,6 +11524,16 @@
1152411524
"source_path": "hub/apps/desktop/modernize/modernize-wpf-tutorial-5.md",
1152511525
"redirect_url": "/windows/apps/desktop/modernize/",
1152611526
"redirect_document_id": false
11527+
},
11528+
{
11529+
"source_path": "hub/apps/develop/background-processing/index.md",
11530+
"redirect_url": "/windows/apps/develop/app-lifecycle-and-system-services",
11531+
"redirect_document_id": false
11532+
},
11533+
{
11534+
"source_path": "hub/apps/windows-app-sdk/applifecycle/app-background-task.md",
11535+
"redirect_url": "/windows/apps/windows-app-sdk/applifecycle/background-tasks",
11536+
"redirect_document_id": false
1152711537
}
1152811538
]
11529-
}
11539+
}

hub/apps/develop/app-lifecycle-and-system-services.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,4 @@ The .NET SDK also provides APIs related to system services for WPF and Windows F
6262
|---------|-------------|
6363
| [Threading model (WPF)](/dotnet/framework/wpf/advanced/threading-model) | Learn about the threading model of WPF apps. |
6464
| [System information](/dotnet/framework/winforms/advanced/system-information-and-windows-forms) | Learn how to access system information in Windows Forms apps. |
65+
| [.NET Worker Services](/dotnet/core/extensions/workers) | A lightweight way to run long-running background workloads in .NET apps. No packaging required — works with any WPF, Windows Forms, or console app deployment model. |

hub/apps/windows-app-sdk/applifecycle/background-tasks.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ ms.localizationpriority: medium
1010

1111
# Using background tasks in Windows apps
1212

13-
This article provides an overview of using background tasks and describes how to create a new background task in a WinUI 3 app. For information about migrating your UWP apps with background tasks to WinUI, see the Windows App SDK [Background task migration strategy](../migrate-to-windows-app-sdk/guides/background-task-migration-strategy.md).
13+
> [!IMPORTANT]
14+
> Background tasks using the Windows App SDK `BackgroundTaskBuilder` require your app to be **packaged with MSIX**. For WPF or Windows Forms apps deployed without MSIX packaging, use [Task Scheduler](/windows/win32/taskschd/task-scheduler-start-page) or [.NET Worker Services](/dotnet/core/extensions/workers) instead.
15+
16+
This article provides an overview of using background tasks and describes how to create a new background task in a WinUI 3 or other MSIX-packaged app (including WPF and Windows Forms). For information about migrating your UWP apps with background tasks to WinUI, see the Windows App SDK [Background task migration strategy](../migrate-to-windows-app-sdk/guides/background-task-migration-strategy.md).
1417

1518
Background tasks are app components that run in the background without a user interface. They can perform actions such as downloading files, syncing data, sending notifications, or updating tiles. They can be triggered by various events, such as time, system changes, user actions, or push notifications. These tasks can get executed when corresponding trigger occurs even when the app is not in running state.
1619

hub/apps/windows-app-sdk/migrate-to-windows-app-sdk/wpf-plus-winappsdk.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,21 @@ Build and run again. Click the button, and confirm that a toast notification is
149149
> [!NOTE]
150150
> The steps in this section showed you how to create a *packaged app*. An alternative is to create a *packaged app with external location*. For a reminder of all these terms, see [Advantages and disadvantages of packaging your app](/windows/apps/package-and-deploy/).
151151
152+
## Run code in the background
153+
154+
For WPF apps that need to execute code when the app isn't running, there are three approaches depending on your packaging and workload:
155+
156+
| Approach | Packaging required | Best for |
157+
|---|---|---|
158+
| [Windows App SDK background tasks](../applifecycle/background-tasks.md) | Yes (MSIX) | Power-efficient system-managed triggers (time/system) |
159+
| [Task Scheduler](/windows/win32/taskschd/task-scheduler-start-page) | No | Periodic sync, unpackaged apps |
160+
| [.NET Worker Services](/dotnet/core/extensions/workers) | No | Long-running headless workloads, any deployment model |
161+
162+
For Windows App SDK background tasks, your WPF app registers a COM component using `BackgroundTaskBuilder` just like a WinUI 3 app — the `Application.Startup` event in WPF maps to the role that `App.OnLaunched` plays in WinUI 3. See [Using background tasks in Windows apps](../applifecycle/background-tasks.md) for the full walkthrough.
163+
164+
> [!NOTE]
165+
> Windows App SDK background tasks require MSIX packaging. For unpackaged WPF apps, use Task Scheduler or .NET Worker Services instead.
166+
152167
## Related topics
153168

154169
* [Windows Presentation Foundation (WPF)](/dotnet/desktop/wpf/)

uwp/launch-resume/support-your-app-with-background-tasks.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ ms.localizationpriority: medium
99
---
1010
# Support your app with background tasks
1111

12+
> [!NOTE]
13+
> This page covers the **UWP-specific** background task model (`IBackgroundTask`, `BackgroundTaskBuilder`). For WPF and Windows Forms apps, use the corresponding [Background tasks (Windows App SDK)](/windows/apps/windows-app-sdk/applifecycle/background-tasks) guidance for packaged desktop apps (different namespaces, registration steps, and MSIX packaging requirements), or consider [Task Scheduler](/windows/win32/taskschd/task-scheduler-start-page) (no packaging required) or [.NET Worker Services](/dotnet/core/extensions/workers) (no packaging required).
1214
1315
The topics in this section show you how to make lightweight code run in the background in response to triggers. You can use background tasks to provide functionality when your app is suspended or not running. You can also use background tasks for real-time communication apps like VOIP, mail, and IM.
1416

0 commit comments

Comments
 (0)