My Win RT application which has worked with VS2012RC on a Windows 8 beta, has now with the final versions of visual studio and windows 8 pro the problem, that creating/opening a file within OnSuspending only works if I set a debugger-breakpoint to the file creation method.
private void OnSuspending(object sender, SuspendingEventArgs e){
var deferral = e.SuspendingOperation.GetDeferral();
if (null != m_document) Save();
deferral.Complete();
}
async void Save(){
var folder = KnownFolders.DocumentsLibrary;
var file = await folder.CreateFileAsync(GetFileName(),Windows.Storage.CreationCollisionOption.ReplaceExisting);
var xDoc = GetXDocument();
using (var stream = await file.OpenStreamForWriteAsync()){
xDoc.Save(stream);
}
}
If I set a breakpoint on
StorageFile file = await folder.CreateFileAsync(...
, the debugger enters the and if I continue, all works fine.However if I dont set a breakpoint, the file will be created, but the content of the xml will not be saved (the file rests empty).
If I set a breakpoint below of the line
StorageFile file = await folder.CreateFileAsync(...
, the debugger never enters!
Has anyone an idea? I have also tested a version which uses folder.OpenStreamForWriteAsync
, with the very same effect.