PC Review


Reply
Thread Tools Rate Thread

ASP.NET AppDomain - User code at Initialization

 
 
csprakash@yahoo.com
Guest
Posts: n/a
 
      14th Jan 2008
Hi All,
I want to run some user when an Application is started, or when a
worker process is started. Application_Start, Init methods of
HttpApplication in Global.asax.cs are of not use, as they are called
only on the first call to an aspx page in the application. They are
not called during the initialization of the worker process (or)
Application Domain.

Is this possible at all? I came accross a delegate
"AppDomainInitializer", is this of any use? Can it be configured in
IIS to invoke user code?

Any inputs/pointers will be very helpful.

Thanks,
Ashton
 
Reply With Quote
 
 
 
 
Michael Nemtsev [MVP]
Guest
Posts: n/a
 
      14th Jan 2008
Hello (E-Mail Removed),

What exactly behavior u need and why Application_Start is inappropriate?

Im not quite understand how u gonna hook the AppDomain when asp.net starts
to add AppDomainInitializer event

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


> Hi All,
> I want to run some user when an Application is started, or when a
> worker process is started. Application_Start, Init methods of
> HttpApplication in Global.asax.cs are of not use, as they are called
> only on the first call to an aspx page in the application. They are
> not called during the initialization of the worker process (or)
> Application Domain.
>
> Is this possible at all? I came accross a delegate
> "AppDomainInitializer", is this of any use? Can it be configured in
> IIS to invoke user code?
>
> Any inputs/pointers will be very helpful.
>
> Thanks,
> Ashto



 
Reply With Quote
 
Ashton
Guest
Posts: n/a
 
      14th Jan 2008
My requirement is - I have a time consuming Initialization that needs
to be done before any page is accessed on the site. At present I am
using Application_Start. The initialization takes around 3 minutes.
-------------
Application_Start(..)
{
......
myObj = new MyClass(); // takes 3 minutes, performs singleton type of
initialization internally
}
-------------

So, when I first access the site, the browser looks frozen. I dont
want the initialization to wait till a request comes, if it can start
as soon as the IIS ApplicationPool is started or recycled, that will
be ideal.

I had few alternatives, but none of them are elegant:

1)
On a machine restart, after IIS service comes up, I can have a bat
script which tries to access the site, which performs the
intialization.
This works fine, but the worker processes need to be recycled
every hour or so for some data requirement. Whenever the worker
process is recycled, it waits till it receives the first request for
the Application. On the first request, the users feel the site is
frozen.

2) tried various other methods in Global.asax.cs (HttpApplication),
------------
init()
{
......
myObj = new MyClass(); // takes 3 minutes, performs singleton type of
initialization internally
}
---------
static global()
{
......
myObj = new MyClass(); // takes 3 minutes, performs singleton type of
initialization internally
}

but both of them are invoked on the first http request to the
Application.

3) I came across Microsoft.Web.Administration ServerManager, Site,
ApplicationPool, ApplicationDomain classes. Can anyof them be used to
start HttpApplication even before an external http request comes?

Regards
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET AppDomain - User code at Initialization csprakash@yahoo.com Microsoft Dot NET Framework 2 14th Jan 2008 11:08 PM
Calling from default AppDomain (native code) into another AppDomain (managed code), hosted by ASP.NET Dave Burns Microsoft ASP .NET 0 12th Jan 2007 03:43 PM
Calling from default AppDomain (native code) into another AppDomain (managed code), hosted by ASP.NET Dave Burns Microsoft VC .NET 2 12th Jan 2007 03:41 PM
Calling from default AppDomain (native code) into another AppDomain (managed code), hosted by ASP.NET Dave Burns Microsoft Dot NET Framework 2 12th Jan 2007 03:41 PM
Calling from default AppDomain (native code) into another AppDomain (managed code), hosted by ASP.NET Dave Burns Microsoft ASP .NET 2 12th Jan 2007 03:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:27 AM.