Convert an out-of-process background task to an in-process background task
The simplest way to convert your out-of-process background activity into in-process activity is to bring your IBackgroundTask.Run method code inside your application and initiate it from OnBackgroundActivated.
If your app has multiple background tasks, the Background Activation Sample shows how you can use
BackgroundActivatedEventArgs.TaskInstance.Task.Name to identify which task is being initiated.
If you are currently communicating between background and foreground processes, you can remove that state management and communication code.