Skip to content

Commit 38d61ee

Browse files
Add background tasks section to WPF + Windows App SDK page
New '## Run code in the background' section with a comparison table of the three approaches (WAS background tasks, Task Scheduler, Worker Services), packaging requirements for each, and a note on how Application.Startup maps to App.OnLaunched for WAS background task registration. Fixes Gap 10 from ADO #568630. Co-authored-by: Copilot <[email protected]>
1 parent a00af75 commit 38d61ee

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

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](../../windows-app-sdk/applifecycle/background-tasks.md) | Yes (MSIX) | Power-efficient system-managed triggers (time, network, push) |
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](../../windows-app-sdk/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/)

0 commit comments

Comments
 (0)