Is XTrace.Listeners thread safe?

0
I need to know if and where threads come into play when dealing with adding/removing listeners from the collection? Here is my code: Dim textWriterListener As UltimateTextWriterTraceListener = New UltimateTextWriterTraceListener(fileName) If (Not XTrace.Listeners.Contains(textWriterListener)) Then XTrace.Listeners.ForEach(Sub(x As UltimateTextWriterTraceListener) x.Dispose) XTrace.Listeners.Clear XTrace.Level = TraceEventType.Verbose XTrace.Listeners.Add(textWriterListener) End If I'm concerned about disposing of a listener that may be used by an existing thread. Does the Clear dispose of all listeners? What is the proper way to accomplish this? Will the XTrace.Listeners collection be immediately available for adding a new listener after the Clear?
 
asked 8/14/2020 8:14:14 PM
add a comment

1 Answers

0
`UltimateTraceListenerCollection` is thread safe. Instead of calling `XTrace.Listeners.ForEach(Sub(x As UltimateTextWriterTraceListener) x.Dispose)`, you can call XTrace.Close().
 
answered 8/26/2020 3:00:29 PM
add a comment

Your Answer

Not the answer you're looking for? Browse other questions tagged ultimate sftp or ask your own question.