>>>My whole class is static.
>>
>>Do you see any problem I have a local declaration on the lock object?
>>
>>BTW, I do not know if that is related but I am having a problem with some event being logged in the event viewer with this new architecture.
>>
>>Application: w3wp.exe
>>Framework Version: v4.0.30319
>>Description: The process was terminated due to stack overflow.
>>
>>So, when this happens, the application will restart and I then have a bunch of errors.
>
>I might not have seen enough of your code, but how will other instances know about the lFirstHit variable? I created my class and variable as static so it's a singleton throughout the application.
Just a side note Mike for clarification on your comment. You may already realize this. A static object does not constitute a singleton. An instance object can be kept to a single instance through the use of a singleton pattern. An object is referenced through a property and if the instance already exists the existing instance is passed back instead of creating another instance of the object. Here is an example in my EventLogger class. I use it because I want the same event log throughout the application. Notice the constructor is protected so it cannot be constructed directly.
public class EventLogger
{
#region Private Singleton
private static EventLogger instance = null;
private static EventLogger Instance
{
get
{
if(instance == null)
instance = new EventLogger();
return instance;
}
}
protected EventLogger()
{
}
#endregion Private Singleton
}
Tim
Timothy Bryan