0

Is it necessary to call Trace.Flush() in the code? Is that an expensive call?

Thanks.

Wizmann
  • 839
  • 1
  • 9
  • 14
  • Surely it depends on how much is stuck in the queue to be written.... but yes, flushing is a good idea. – BugFinder May 26 '16 at 08:05
  • You could call Trace.Flush() once you are done with your Trace.Write type operations. – Ahmer Ali Ahsan May 26 '16 at 08:05
  • See http://stackoverflow.com/questions/17611189/why-would-i-turn-system-diagnostics-trace-autoflush-off – BugFinder May 26 '16 at 08:05
  • A trace listener holds the messages you send it in memory until you Flush() it. – Ahmer Ali Ahsan May 26 '16 at 08:09
  • It depends on the listener. If it writes the trace info to a file then, yes, flushing is pretty expensive. Relatively, it still takes well less than the blink of an eye. Whether that *really* matters to your program is something you have to find out by yourself. – Hans Passant May 26 '16 at 09:48

0 Answers0