WindowsAppSDK icon indicating copy to clipboard operation
WindowsAppSDK copied to clipboard

Setting SystemTrigger or ApplicationTrigger as background task triggers throws exception when registering

Open Diegorro98 opened this issue 2 years ago • 2 comments

Describe the bug

I'm looking to create Win32 COM background task with Time, System and Application Triggers. Time works, but when System or Application triggers are set, calling BackgroundTaskBuilder.Register throws the following exception

System.Runtime.InteropServices.COMException: "Incompatible request (0x80070032)"

Steps to reproduce the bug

In BackgroundTaskWinMainComSample/CS project from DesktopBridgeToUWP-Sample repository I'm able to replicate the issue.

Only thing needed to update is at MainWindow.xaml.cs:172, change the Time trigger by any of the others mentioned:

RegisterBackgroundTaskWithSystem(new SystemTrigger(SystemTriggerType.SessionConnected, false), typeof(TimeTriggeredTask).GUID, typeof(TimeTriggeredTask).Name);
RegisterBackgroundTaskWithSystem(new ApplicationTrigger(), typeof(TimeTriggeredTask).GUID, typeof(TimeTriggeredTask).Name);

Expected behavior

It should be able to register the task and triggers should work.

Screenshots

No response

NuGet package version

Windows App SDK 1.4.0: 1.4.230822000

Packaging type

Packaged (MSIX)

Windows version

Insider Build (xxxxx)

IDE

Visual Studio 2022

Additional context

No response

Diegorro98 avatar Sep 05 '23 15:09 Diegorro98

@bpulliam what's the status here?

stevenbrix avatar Jan 09 '24 23:01 stevenbrix

Same issue here, I am trying to use new SystemTrigger(SystemTriggerType.TimeZoneChange, false)

tipa avatar Jan 16 '24 10:01 tipa