views:

54

answers:

1

Hi

I have some code that initializes a static singleton class, which is needed by all requests. Therefore I thought I could add it to global.asax Application_Start. Can I be 100% sure that all requests will block while Application_Start is loading to guarantee that all the requests will have access to it?

Thanks a lot Jeeji

+1  A: 

Short answer: yes.

Application_Start:

Called when the first resource (such as a page) in an ASP.NET application is requested. The Application_Start method is called only one time during the life cycle of an application. You can use this method to perform startup tasks such as loading data into the cache and initializing static values.

You should set only static data during application start. Do not set any instance data because it will be available only to the first instance of the HttpApplication class that is created.

http://msdn.microsoft.com/en-us/library/ms178473.aspx

camainc
If this answer is correct, then why not accept it? Thanks.
camainc