![]() |
|
[C#] Writing to a text file really inneficient [C#] - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C#] Writing to a text file really inneficient [C#] (/showthread.php?tid=6070288) |
Writing to a text file really inneficient [C#] - draxyee - Apr 22, 2020 I'm using this code to write to a text file using many threads at the same time. (Parallel.Foreach a list) with a high thread count. However, I've noticed that multi thread doesn't increase the speed from a normal foreach when using this method. PHP Code Is there any other efficient way to output a lot of data to somewhere (preferably to a file)? I need it to be super super quick. Cheers RE: Writing to a text file really inneficient [C#] - __Digital__ - Apr 22, 2020 (Apr 22, 2020 01:49 PM)draxyee Wrote: I'm using this code to write to a text file using many threads at the same time. (Parallel.Foreach a list) with a high thread count. try using streamwriter it might help you RE: Writing to a text file really inneficient [C#] - Shadow_Cloud - Apr 22, 2020 I would strongly advise log4net for this Code class ProgramHave a look here > https://stackify.com/log4net-guide-dotnet-logging/ RE: Writing to a text file really inneficient [C#] - Sickness - Apr 23, 2020 static Streamwriter text = new Steamwriter("file.txt", true); That line in top of main. Inside main: text.Autoflush = true; text.WriteLine(string); RE: Writing to a text file really inneficient [C#] - Shadow_Cloud - Apr 23, 2020 (Apr 23, 2020 08:13 AM)Sickness. Wrote: static Streamwriter text = new Steamwriter("file.txt", true); By default, a StreamWriter is not thread safe. |