Search code examples
uwpwindows-10counterstartup

UWP Windows 10: Is there a variable counting app starts?


do UWP apps for Windows 10 contain a variable counting the number of startups? If yes, what is the name of this variable? I want to perform an event after a certain number of app starts. Otherwise i need to develop a startup Counter manually.

Thanks! :)


Solution

  • I think this could work:

        Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
    
        public MainPage()
        {
            this.InitializeComponent();
    
            //Count App starts
            object Counter = localSettings.Values["AppStartCounter"];
    
            if (Counter != null)
            {
                localSettings.Values["AppStartCounter"] = (int)Counter + 1;
            }
            else
            {
                localSettings.Values["AppStartCounter"] = 1;
            }
         }