c# - Write large data with WriteLineAsync in a using block -
can following code cause error, if writelineasync not finished writing, using term tries dispose writer stream?
for example:
using (var writer = system.io.file.appendtext(filename)) { writer.writelineasync(message); } what happen, if write large data, may takes few seconds?
thank you
yes, stream disposed of before task has completed.
you should either await task returned writelineasync or write file synchronously instead, using writeline.
Comments
Post a Comment