I am writing a C# application.
I have (a kind of) logging class. and this logging class will be used by many threads.
How to make this class thread safe?
Should I make it as singleton?
what are the best practices there?
Is there a document that I can read about how to make it thread-safe?
Thanks
In C#, any object can be used to protect a "critical section", or in other words, code that must not be executed by two threads at the same time.
For example, the following will synchronize access to the SharedLogger.Write method, so only a single thread is logging a message at any given time.