locked
Write to trace file in sequential order

    Question

  • I have this piece of code:

    var traceFile = Windows.Storage.ApplicationData.current.localFolder.createFileAsync("trace.txt", Windows.Storage.CreationCollisionOption.openIfExists);
    var lastWriter = traceFile;
    function trace(data) {
      lastWriter.then(function (file) {
        lastWriter = Windows.Storage.FileIO.appendTextAsync(file, data).then(function () {
          return file;
        });
      });
    }
    

    and I want to call the trace method from everywhere in the program. It seems that it does not write all the date I throw at it.

    Where is the glitch?

    Wednesday, August 6, 2014 10:52 PM

All replies

  • Probably call the function everywhere may cause the file access conflict?

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, August 7, 2014 6:26 AM
    Moderator
  • No, there is no exception thrown. And when stepping through the code with the debugger all entries are written. So it seems more like a timing issue. But I fail to see whats wrong with my promise chaining.
    Thursday, August 7, 2014 7:34 AM