Daniel Hitzel Daniel Hitzel - 1 month ago 22
C# Question

Windows 10 - Background Task write to App's Calendar

Can a Windows 10 UWP

BackgroundTask
use the
ApplicationModel
namespace of the actual app to do things like writing
Appointments
to an
AppointmentCalendar
?

From what I have read
BackgroundTask
to
App
communication is limited to exchanging messages via e.g.
LocalStorage
.
But what the point of this limitation, if I want to really change the state of an app from a
BackgroundTask
?

Answer

Can a Windows 10 UWP BackgroundTask use the ApplicationModel namespace of the actual app to do things like writing Appointments to an AppointmentCalendar?

Just have a test, writing Appointments to AppointmentCalendar in background task seems to be not possible now, no matter the background task is hosted in the system's background host(out-of-process background task) or in the application's process(in-process background task), it is not allowed to write to AppointmentCalendar.

But what the point of this limitation, if I want to really change the state of an app from a BackgroundTask?

For this question, @Petesh has answered the part when your background task is hosted out process, when it is in process, it is allowed to communicate with the foreground application, but only with the same process, not with the out process application like Calendar.

By changing the state of an app, what you mean, you want to launch an app from background task? If so, I'm afraid to tell you that when you launch an app, your app must be the foreground app, that is, it must be visible to the user.