473,836 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

intercept shutdown of a IIS garden process to terminate a bkgd thr

I have a ASP.NET webservice and it is configured to run in a web garden with
multiple processes.

Whan a process in the garden is launched, I want the process to create a
background thread. When request are received by this instance of the garden
process, a meessage is posted to the background thread to do its work. When
the garden process is being down by IIS (due to a period of inactivity), I
want to notify the background thread to gracefully terminate.

I create and launch the background thread when a method is the webservice is
first invoked. How do I intercept the shutdown event for the garden process
to terminate the background thread?

According to MSDN documentation, Application_End is not the place to do it
because it is called when the ASP.NET application is shutdown and not
instances of the garden process.

Thanks.
Apr 26 '06 #1
5 3183
Welcome to the ASP.NET newsgroup.

From your description, I understand you've developed an ASP.NET webservice,
the service will launch a background thread for task processing. Also,
you're curently configuring the webservice application as webgarden mode in
IIS, so you're wondering what's the proper place to intercept the startup
and shutdown of the IIS webgarden process so that you can gracefully
clearup the background thread, correct? If anything I didn't quite get,
please feel free to let me know.

Based on my understanding, for ASP.NET webservice application, it is the
same with the ASP.NET web page based application, the Application_Sta rt,
and Application_End events are the two ones we can use to do some startup
and shutdown tasks. And for IIS worker process, there is not interfaces for
us to intercepting its startup and shutdown in managed code.

Actually, the Application_End and Application_Sta rt events are the
reasonable ones for your scenario, because these two events are specific to
ASP.NET application's runtime appdomain(AppDo main's startup and AppDomain's
teardown). So when we're creating background threads in our asp.net
application, the thread(managed thread) is associated with its host
AppDomain, so when the application restart, the background thread will also
be disposed, so it's reasonable to put the clearup code in Application_End
event.

In addition, for IIS6, there provides the application pool process
isolation model, we can create a particular application pool for our
webservice application. Thus, each webgarden worker process is associated
with that particular application pool and the worker process will contains
only our web service appliation's AppDomain, this can help isolated our
application from other web application well.

Hope this helps some. Please feel free to post here if you have any other
consideration.

Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Apr 27 '06 #2
Steven,

Thanks for the reply. Your understanding of my question is correct.

You recommend that the cleanup be done at Application_End . However,
according to MSDN documentation, it indicates that Application_End is
exeucted for the ASP.NET application when it shuts down and it is not called
during each garden instance being shutdown.

Did I misread the MSDN documentation? Thanks.

"Steven Cheng[MSFT]" wrote:
Welcome to the ASP.NET newsgroup.

From your description, I understand you've developed an ASP.NET webservice,
the service will launch a background thread for task processing. Also,
you're curently configuring the webservice application as webgarden mode in
IIS, so you're wondering what's the proper place to intercept the startup
and shutdown of the IIS webgarden process so that you can gracefully
clearup the background thread, correct? If anything I didn't quite get,
please feel free to let me know.

Based on my understanding, for ASP.NET webservice application, it is the
same with the ASP.NET web page based application, the Application_Sta rt,
and Application_End events are the two ones we can use to do some startup
and shutdown tasks. And for IIS worker process, there is not interfaces for
us to intercepting its startup and shutdown in managed code.

Actually, the Application_End and Application_Sta rt events are the
reasonable ones for your scenario, because these two events are specific to
ASP.NET application's runtime appdomain(AppDo main's startup and AppDomain's
teardown). So when we're creating background threads in our asp.net
application, the thread(managed thread) is associated with its host
AppDomain, so when the application restart, the background thread will also
be disposed, so it's reasonable to put the clearup code in Application_End
event.

In addition, for IIS6, there provides the application pool process
isolation model, we can create a particular application pool for our
webservice application. Thus, each webgarden worker process is associated
with that particular application pool and the worker process will contains
only our web service appliation's AppDomain, this can help isolated our
application from other web application well.

Hope this helps some. Please feel free to post here if you have any other
consideration.

Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Apr 27 '06 #3
Thanks for your response,

Your understanding on the "Application_En d" event is correct, it is
exeucted for the ASP.NET application when it shuts down. Actually so far we
haven't any built-in .net events or interface to intercepting IIS worker
process's shutdown or recycle. However, when IIS worker process( the
webgarden process shutss down, the application will certainly be shutdown
first, so this event will be triggered too).

Also, as I mentioned in the former message, ASP.NET managed threads are
associated with appdomain, and ASP.NET application instance is just an
AppDomain, so when the application restart or shutdown, those managed
threads associated with this appdomain will also be destroyed. Therefore I
think the Application_End event is appropriate for doing cleanup for your
background thread. How do you think?

In addition, for your webgarden scenairo, each worker process(in your ase
there will have at most 3 ones) will contains an appDomain for your ASP.NET
application, and when any of them(Appdomain) are restarted, or shutdown,
the Application_End event will fire for that certain AppDomain.

Hope this makes it clear. If there is still anything I missed, or anything
we can help, please feel free to let me know.

Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Apr 28 '06 #4
Thank you very much for your response and assistance on this.

"Steven Cheng[MSFT]" wrote:
Thanks for your response,

Your understanding on the "Application_En d" event is correct, it is
exeucted for the ASP.NET application when it shuts down. Actually so far we
haven't any built-in .net events or interface to intercepting IIS worker
process's shutdown or recycle. However, when IIS worker process( the
webgarden process shutss down, the application will certainly be shutdown
first, so this event will be triggered too).

Also, as I mentioned in the former message, ASP.NET managed threads are
associated with appdomain, and ASP.NET application instance is just an
AppDomain, so when the application restart or shutdown, those managed
threads associated with this appdomain will also be destroyed. Therefore I
think the Application_End event is appropriate for doing cleanup for your
background thread. How do you think?

In addition, for your webgarden scenairo, each worker process(in your ase
there will have at most 3 ones) will contains an appDomain for your ASP.NET
application, and when any of them(Appdomain) are restarted, or shutdown,
the Application_End event will fire for that certain AppDomain.

Hope this makes it clear. If there is still anything I missed, or anything
we can help, please feel free to let me know.

Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Apr 28 '06 #5
Glad to be of assistance.

If you meet any new problem or anything else we can help, please feel free
to post here.

Good luck!

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

May 1 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2080
by: Hannes Grund | last post by:
Dear all, probably offtopic for the general python list, but I don't know were to go else. I'm currently developing somekind of middleware wich makes heavy use of pythonwin/com extensions. (The complete setup is: win2000/winXP, python2.2, win32all-152, wxPython resp. wxWindows). The software is aimed to manage data held by a software
2
4641
by: Austin | last post by:
I wrote a program running on windows. I put the link of the program in "Start up" folder and let it executed minimized. Every time when I open the computer, my program will be running in system tray. But if the user would like to shutdown the computer, the OS will show an error about exception. At first, I think windows will terminate all processes when it shutdown.
8
2772
by: Jonathan Heath | last post by:
Hi all, I have created an ASP script that enters data into an Access Database. My problem is that I'd like this script to run when the computer is shutdown or the user logs off. I think this would be simple enough if the ASP didn't have any user input, but it does.
2
1613
by: Jack | last post by:
It seems that if Finalize takes more than 2 seconds during the process shutdown, the process will just terminate anyway. How can I specifically tells GC that this guy's clean up does suppose to take that long so that please wait until I finish my job gracefully?
0
1375
by: kelvlam | last post by:
I have written a service that is depending on mysqld. The service startup just fine, but I would like to have my service *always* shutdown first before mysqld does. That way I can add some log into my table before the service shutdown. As I search online, I haven't found any way to do so. Since the "service dependencies" setting of services is only used at startup stage, but not at shutdown stage. Is there any way to intercept the...
3
5498
by: Jon Bosker | last post by:
I have written an application that lives in the systray but when I try to close windows or logout it does not close my application and therefore prevents windows from shutting down or logging me out. It is essential that I solve this problem but I have run out of ideas can anyone help (please!) The application starts in Start.cs which kicks off the Systray form using this call: Application.Run(new Systray());
6
8769
by: carbon_dragon | last post by:
Ok, so here is the problem. I'm working on a headless server program implemented as a .NET C# Console project. There is a UPS mounted to this server (though not a windows compliant UPS). I can only talk to the UPS over a special device driver. Through this device driver I can detect that the UPS is going to notify Windows 2000 server to shut down. So I start doing a graceful termination. But Windows shuts down pretty quickly and there...
10
10619
by: Steve | last post by:
Does any one know if python has the ability to run a shutdown hook. For example you set a method to run when the python process is shutting down, like it recieved a kill signal? Basically looking for an effect like the following java code. Runtime.getRuntime().addShutdownHook(new Thread(this));
5
4583
by: Cramer | last post by:
I think I understand *what* a Web garden is (app running on a server with multiple processors). But what's the benefit? I have googled this and have found only articles that describe WHAT and HOW to set up a Web garden, but not WHY - what's the advantage, and how would I take advantage of the multiple processors? Is it as simple as me making my app multi-threaded whereever it is possible and makes sense to do so? If I run an ASP.NET...
0
9820
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10548
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10591
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9374
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5649
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4452
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4016
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3115
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.