M
Moe Sisko
According to the documentation, instance members of the TraceSwitch class
are not guaranteed to be thread safe.
Consider the following code :
==
in class "A":
public static TraceSwitch BlahSwitch = new TraceSwitch("blah",
"blah");
in class "B" :
private void DoSomething()
{
if (A.BlahSwitch.TraceError)
System.Diagnostics.Trace.WriteLine("Error occured");
==
In doing some testing, I saw cases where BlahSwitch.TraceError sometimes had
the incorrect value. (To reproduce this, I created mulitple threads in a
winform app, and accessed BlahSwitch.TraceError from different threads at
the same time).
So, I'm wondering if using static instances of TraceSwitch is a good idea in
ASP.NET ?
Otherwise, creating a local instance of the TraceSwitch everytime it is
needed seems very inefficient.
are not guaranteed to be thread safe.
Consider the following code :
==
in class "A":
public static TraceSwitch BlahSwitch = new TraceSwitch("blah",
"blah");
in class "B" :
private void DoSomething()
{
if (A.BlahSwitch.TraceError)
System.Diagnostics.Trace.WriteLine("Error occured");
==
In doing some testing, I saw cases where BlahSwitch.TraceError sometimes had
the incorrect value. (To reproduce this, I created mulitple threads in a
winform app, and accessed BlahSwitch.TraceError from different threads at
the same time).
So, I'm wondering if using static instances of TraceSwitch is a good idea in
ASP.NET ?
Otherwise, creating a local instance of the TraceSwitch everytime it is
needed seems very inefficient.