I am designing an uwp app with multiple instances, I want to sync settings across all instances so that when I change a setting in one instance all the instances produce the same effect. How do I go about this??
The right way to detect changes in settings across multiple instances is handle ApplicationData.DataChanged
event across all instances and after changing any settings execute ApplicationData.SignalDataChanged()
which will invoke ApplicationData.DataChanged
across all instances. Loading the Localsettings
when DataChanged
event is fired or storing the key of LocalSettings
changed before executing ApplicationData.SignalDataChanged()
and only reloading settings with that specific key are the ways to handle changes in LocalSettings
.
Create an out-of-proc appservice as explained in this article, disable multiinstance for appservice. In the appservice code along with storing the created appservice connection store a static list of all the appservice created by all the new app instance. Whenever settings is changed send response to the appservice and from the service relay that message to all other app instance stored in static list. In the app itself react to settings changes when response is recieved. Also manage/update the list when an app instance is closed.
The right way to detect changes in settings across multiple instances is handle ApplicationData.DataChanged
event across all instances and after changing any settings execute ApplicationData.SignalDataChanged()
which will invoke ApplicationData.DataChanged
across all instances. Loading the Localsettings
when DataChanged
event is fired or storing the key of LocalSettings
changed before executing ApplicationData.SignalDataChanged()
and only reloading settings with that specific key are the ways to handle changes in LocalSettings
.
© 2022 - 2024 — McMap. All rights reserved.