Sync settings and update changes across all instances in multiple instance uwp app

荒凉一梦 提交于 2021-01-29 13:28:45

问题


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??


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/61287741/sync-settings-and-update-changes-across-all-instances-in-multiple-instance-uwp-a

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!