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
Post a Comment