ThangBM
ThangBM

Reputation: 301

BackgroundTaskDeferral.Complete does not work when application run without debugging in UWP app

BackgroundTaskDeferral.Complete works normally when the application runs with debugging, the main project can catch OnComplete event even when the app is suspended.

But when the app runs without debugging and the app goes to background, BackgroundTaskDeferral.Complete does not work. the main project can not receive anything when background task call (when main project catch event OnComplete I will show a toast notification)

BackgroundTaskDeferral _deferral = taskInstance.GetDeferral();
_deferral.Complete();

Upvotes: 0

Views: 291

Answers (1)

Romasz
Romasz

Reputation: 29792

If I understood you correct, the problem is that your main project doesn't get notified one Background Task completes its work. It's normal - your main project is being suspended by the OS, shortly after your app goes to background.

It works while you are debugging, hence the PLM is disabled and suspending/resuming events are not being raised.

If you want to perform some job in the background - put it inside background task, sending toast notification should work fine.

Upvotes: 1

Related Questions