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

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -