Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / January 2008

Tip: Looking for answers? Try searching our database.

ASP.NET AppDomain - User code at Initialization

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
csprakash@yahoo.com - 14 Jan 2008 18:30 GMT
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
Michael Nemtsev [MVP] - 14 Jan 2008 20:50 GMT
Hello csprakash@yahoo.com,

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
[quoted text clipped - 12 lines]
> Thanks,
> Ashto
Ashton - 14 Jan 2008 23:08 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.