I have a wpf app writing to a text logfile fairly infrequently (from 0.25s to 4s between writes).
Each write is one short line of text.
I don’t flush after every write.
At the moment, this is called directly on the main UI thread, as I figure the length of time taken isn’t even beginning to become close to being a concern.
..Is the right way to do it, though?
Should I have the logging process on it’s own thread, and send some asynchronous event to it to log the data?
Have a look at NLog, Spring or any of the multitude of logging platforms. Make your app cool and worry about the best way to do logging later. Logging calls will be made from your gui methods, how they are implemented should be abstracted onto a framework so you can put them on different threads etc. if required.