Friday 15 August 2014

c# - ApplicationData.LocalSettings not storing data? -


I am creating an app where access is entered twice for value (startshore, startmoon, endor, endeminate) is. I have written a function that saves values ​​and then checks for value and adds value inside text box. However, this is not working and I am not sure why I am considering its fault on my part, but I am not sure at all. Here's the code:

  Public async Task saved () {while (true) {var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; local Settings. Value ["starthour1"] = starthour1.Text; local Settings. Value ["starthour2"] = starthour2.Text; local Settings. Value ["starthour3"] = starthour3.Text; local Settings. Value ["starthour4"] = starthour4.Text; local Settings. Value ["starthour5"] = starthour5.Text; local Settings. Value ["starthour6"] = starthour6.Text; local Settings. Value ["starthour7"] = starthour7.Text; local Settings. Value ["startminute1"] = startminute1.Text; local Settings. Value ["startminute2"] = startminute2.Text; local Settings. Value ["startminute3"] = startminute3.Text; local Settings. Value ["startminute4"] = startminute4.Text; local Settings. Value ["startminute5"] = startminute5.Text; local Settings. Value ["startminute6"] = startminute6.Text; local Settings. Value ["startminute7"] = startminute7.Text; local Settings. Price ["Endor 1"] = Endor 1Text; local Settings. Price ["Endor 2"] = Endor 2. Text; local Settings. Price ["Endor 3"] = Endor 3. Lesson; local Settings. Price ["Endor 4"] = Endor 4 Text; local Settings. Price ["Endor 5"] = Endor 5 Text; local Settings. Price ["Endor 6"] = Endor 6 Text; local Settings. Price ["Andor 7"] = Endor 7 Text; local Settings. Value ["end minute 1"] = end 1 text; local Settings. Price ["end minute 2"] = last minute 2 Text; local Settings. Price ["end minute 3"] = ending in end 3. Text; local Settings. Value ["interim 4"] = last minute 4 text; Local settings.value ["endinatum5"] = endemanewater 5. Text; local Settings. Value ["endinetum 6"] = endanniction 6 text; local Settings. Value ["endinatum 7"] = endindium 7. Text; // Get the data object starthour1o = local settings.value ["starthour1"]; If (starthour1o == faucet) {// no data} other {starthour1.Text = starthour1o.ToString (); } Object starthour2o = localSettings.Values ​​["starthour2"]; If (starthour2o == faucet) {// no data} and {starthour2.Text = starthour2o.ToString (); } Object starthour3o = localSettings.Values ​​["starthour3"]; If (starthour3o == faucet) {// no data} and {starthour3.Text = starthour3o.ToString (); } Object starthour4o = localSettings.Values ​​["starthour4"]; If (starthour4o == faucet) {// no data} other {starthour4.Text = starthour4o.ToString (); } Object starthour5o = localSettings.Values ​​["starthour5"]; If (starthour5o == faucet) {// no data} other {starthour5.Text = starthour5o.ToString (); } Object starthour6o = localSettings.Values ​​["starthour6"]; If (starthour6o == faucet) {// no data} and {starthour6.Text = starthour6o.ToString (); } Object starthour7o = localSettings.Values ​​["starthour7"]; If (starthour7o == faucet) {// no data} and {starthour7.Text = starthour7o.ToString (); } Waiting for the job. Della (10); }}    

You need to do two things, first you have to clear your settings To be persuaded by calling for them, anywhere in your code you need to do localSettings.Save () and it should work.

2, if you have saved the settings, your code will be overwritten with the first thing in the text box, the current value of the whole top section, where it is localSettings.Values ​​[" Foo "] = Foo.Text should be moved down.

As a side-side comment, do you really need to update your code every 10 milliseconds? She will eat a ton of resources in your program. A more general approach loads the value on start-up, then save them to shutdown.

No comments:

Post a Comment