c# - OpenStreamForWriteAsync Doesn't finish -


i trying save serialised object file. when call openstreamforwriteasync method ui locks , process never seems end. not sure doing wrong here.

            public async task<string> save(string filename)     {         memorystream ms = new memorystream();         var serializer = new datacontractserializer(typeof(settings));          serializer.writeobject(ms, this);          ms.position = 0;          try         {             using (var fms = await applicationdata.current.localfolder.openstreamforwriteasync(filename, creationcollisionoption.replaceexisting))             {                 serializer.writeobject(fms, this);                 return "saved successfully";             }         }         catch         {             return "could not save.";         }      } 

this first question on stackoverflow, have been long time learner. appreciated.

found problem. not awaiting when calling method. needed call method using:

string result =  await settings.save("settings.xml"); 

will rename method saveasync reminder.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -