locked
Trouble w/ ReadTextAsync and WriteTextAsync RRS feed

  • Question

  • My store app was using ApplicationData.Current.RoamingSettings to store data, but I ran into the limit for the amount of data that can be stored there. So, I changed some of the settings to ApplicationDataCompositeValues to get more storage and that worked better, but I decided that is still not enough storage space.

    So now, I'm trying to use the ApplicationData.Current.RoamingFolder.GetFileAsync()  to Read and Write the data to a file. It's working for the first set of data being read/written, but eventually the app hangs. It appears that the  await FileIO.WriteTextAsync(file,data) times out with no exception thrown.

    The app is reading/writing to the file several times during startup. Note that the class for reading/writing these data is in a separate dll so my background task can read the data too (but the background task is turned off for now).

    Does  ApplicationData.Current.RoamingSettings do a better job of locking so only one thread can read/write at a time?

    Does being is a separate dll matter?

    Any ideas?

    Thursday, January 2, 2014 3:32 AM

Answers

  • Get a hang dump by right-clicking on the application process in task manager -> create dump when the process hangs.

    What I mean by manual locking is that you can use the SystemThreading.Monitor class to implement thread-safe locking in your own application.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by Anne Jing Friday, January 10, 2014 7:29 AM
    Thursday, January 2, 2014 4:47 PM
    Moderator

All replies

  • I don't think that the separate DLL matters at all.  You might get a hang dump for analysis.  If locking is your concern, you can specifically lock the resource manually.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, January 2, 2014 3:18 PM
    Moderator
  • Thanks for the reply. How do I get a hang dump and how do I lock the file? I had read that you cant lock them.

    Thursday, January 2, 2014 4:04 PM
  • Get a hang dump by right-clicking on the application process in task manager -> create dump when the process hangs.

    What I mean by manual locking is that you can use the SystemThreading.Monitor class to implement thread-safe locking in your own application.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by Anne Jing Friday, January 10, 2014 7:29 AM
    Thursday, January 2, 2014 4:47 PM
    Moderator