Hi!
I have found the following problem in TraceSource.
If I use several instances of TraceSource with one shared listener, and threads try to write their first event into TraceSource simultaniously, then several TraceListeners are created.
i.e.: I have multithreading application which works in the following way:
1. First thread creates 2 TraceSource's with name "Name1" and "Name2".
2. First thread creates second and third threads, and run them.
3. Second thread writes an event into first TraceSource.
4. Third thread writes an event into second TraceSource at the same moment as second thread.
After that both threads create TraceListener. I use my own TraceListener - MyTraceListener derived from XmlWriterTraceListener and I can catch both threads in MyTraceListener constructor.
If threads are not so fast and write their events into TraceSources successively, only one MyTraceListener is created.
Is there good workaroung
I used .NET reflector and found, that TraceSource really doesn't do anything to avoid this.