Sunday 15 July 2012

ASP.NET: the static instance will get volatile? -


If I apply a singleton, then insert it in the episode, for example by gc retrieved After each round-trip HTTP requests? Or is it still continuing in order? Thanks for any help.

Public Sealed Class Singleton {Static Text Only Singleton Example = New Singleton (); Static Singleton () {} Singleton () {} Public Stable Singleton Example {Receive; for example; }}}}

No, not every HTTP request. To prove this, I added a readable timestamp to the class:

  public readonly date time timestamp = date time.Now;  

And then it was referenced on a page in the project. It remains the same on each fresh.

You mention GC. Remember that when GC will retrieve an object (even not even GC.) I do not think the object will be retrieved. But I do not think this is a summary of your question.

Actually, yes your singleton will work as a singleton, at least until the application becomes recycled.


No comments:

Post a Comment