Calling Application_Start After Worker Process is Recycled

Discussion in 'ASP .Net' started by headware, Jul 7, 2009.

  1. headware

    headware Guest

    It appears that if the worker process is recycled by IIS, that
    Application_Start is not called again until the next request comes in.
    Is there any way to get this to happen automatically right after the
    process is recycled without relying on a request from a user?

    The basic story behind this is that we have a thread that is created
    in Application_Start and it's supposed to run constantly over the life
    of the application. The user does not want to set up the app pool so
    that the worker process is never recycled. Is there any way around
    this? We could create some kind of dummy client that requests a page
    from the app every so often but I was hoping that there would be a
    more elegant solution.

    Thanks,
    Dave
     
    headware, Jul 7, 2009
    #1
    1. Advertising

  2. headware

    Joy Guest

    Hi Dave,

    Could you elaborate on "what this Thread is doing"?

    The basic premise is that if you want to have a Thread that is always
    running then why not to host it in a Windows Service.

    Why do you need to have a Thread (that is always running) hosted in IIS?

    regards,
    Joy

    "headware" wrote:

    > It appears that if the worker process is recycled by IIS, that
    > Application_Start is not called again until the next request comes in.
    > Is there any way to get this to happen automatically right after the
    > process is recycled without relying on a request from a user?
    >
    > The basic story behind this is that we have a thread that is created
    > in Application_Start and it's supposed to run constantly over the life
    > of the application. The user does not want to set up the app pool so
    > that the worker process is never recycled. Is there any way around
    > this? We could create some kind of dummy client that requests a page
    > from the app every so often but I was hoping that there would be a
    > more elegant solution.
    >
    > Thanks,
    > Dave
    >
     
    Joy, Jul 7, 2009
    #2
    1. Advertising

  3. headware

    headware Guest

    On Jul 7, 2:22 am, Joy <> wrote:
    > Hi Dave,
    >
    > Could you elaborate on "what this Thread is doing"?
    >
    > The basic premise is that if you want to have a Thread that is always
    > running then why not to host it in a Windows Service.
    >
    > Why do you need to have a Thread (that is always running) hosted in IIS?
    >
    > regards,
    > Joy
    >
    > "headware" wrote:
    > > It appears that if the worker process is recycled by IIS, that
    > > Application_Start is not called again until the next request comes in.
    > > Is there any way to get this to happen automatically right after the
    > > process is recycled without relying on a request from a user?

    >
    > > The basic story behind this is that we have a thread that is created
    > > in Application_Start and it's supposed to run constantly over the life
    > > of the application. The user does not want to set up the app pool so
    > > that the worker process is never recycled. Is there any way around
    > > this? We could create some kind of dummy client that requests a page
    > > from the app every so often but I was hoping that there would be a
    > > more elegant solution.

    >
    > > Thanks,
    > > Dave


    The thread is sending out emails based on data in a database. We
    initially discussed putting it into a Windows service but the user was
    opposed to installing a service.

    Dave
     
    headware, Jul 7, 2009
    #3
  4. headware

    Joy Guest

    Hi Dave,

    1. You can have a Timer based Windows Service, that checks for data/specific
    condition and then sends mails.
    2. Else you can have a Timer based Windows service acting as client that
    would call a Web Service which eventually will send mails.

    According to me Windows Service is apt for your case.

    Even if you were to write a dummy client, you will still need to make sure
    that it is running always -> which essentially means you wanna a service that
    would run without user interaction and un-attended.

    regards,
    Joy


    "headware" wrote:

    > On Jul 7, 2:22 am, Joy <> wrote:
    > > Hi Dave,
    > >
    > > Could you elaborate on "what this Thread is doing"?
    > >
    > > The basic premise is that if you want to have a Thread that is always
    > > running then why not to host it in a Windows Service.
    > >
    > > Why do you need to have a Thread (that is always running) hosted in IIS?
    > >
    > > regards,
    > > Joy
    > >
    > > "headware" wrote:
    > > > It appears that if the worker process is recycled by IIS, that
    > > > Application_Start is not called again until the next request comes in.
    > > > Is there any way to get this to happen automatically right after the
    > > > process is recycled without relying on a request from a user?

    > >
    > > > The basic story behind this is that we have a thread that is created
    > > > in Application_Start and it's supposed to run constantly over the life
    > > > of the application. The user does not want to set up the app pool so
    > > > that the worker process is never recycled. Is there any way around
    > > > this? We could create some kind of dummy client that requests a page
    > > > from the app every so often but I was hoping that there would be a
    > > > more elegant solution.

    > >
    > > > Thanks,
    > > > Dave

    >
    > The thread is sending out emails based on data in a database. We
    > initially discussed putting it into a Windows service but the user was
    > opposed to installing a service.
    >
    > Dave
    >
     
    Joy, Jul 8, 2009
    #4
  5. headware

    Joy Guest

    Hi Dave,

    1. You can have a Timer based Windows Service, that checks for data/specific
    condition and then sends mails.
    2. Else you can have a Timer based Windows service acting as client that
    would call a Web Service which eventually will send mails. This makes more
    sense because in this approach you get to harness the Best of both worlds i.e
    having the Web service hosted in IIS, you are letting the IIS take care of
    Memory management (depeneding on your setting of App Pool), security etc and
    having a Timer based client in Windows Service makes sure that you have the
    thread running always.


    According to me Windows Service is apt for your case.

    Even if you were to write a dummy client, you will still need to make sure
    that it is running always -> which essentially means you wanna a service that
    would run without user interaction and un-attended.

    regards,
    Joy




    "headware" wrote:

    > On Jul 7, 2:22 am, Joy <> wrote:
    > > Hi Dave,
    > >
    > > Could you elaborate on "what this Thread is doing"?
    > >
    > > The basic premise is that if you want to have a Thread that is always
    > > running then why not to host it in a Windows Service.
    > >
    > > Why do you need to have a Thread (that is always running) hosted in IIS?
    > >
    > > regards,
    > > Joy
    > >
    > > "headware" wrote:
    > > > It appears that if the worker process is recycled by IIS, that
    > > > Application_Start is not called again until the next request comes in.
    > > > Is there any way to get this to happen automatically right after the
    > > > process is recycled without relying on a request from a user?

    > >
    > > > The basic story behind this is that we have a thread that is created
    > > > in Application_Start and it's supposed to run constantly over the life
    > > > of the application. The user does not want to set up the app pool so
    > > > that the worker process is never recycled. Is there any way around
    > > > this? We could create some kind of dummy client that requests a page
    > > > from the app every so often but I was hoping that there would be a
    > > > more elegant solution.

    > >
    > > > Thanks,
    > > > Dave

    >
    > The thread is sending out emails based on data in a database. We
    > initially discussed putting it into a Windows service but the user was
    > opposed to installing a service.
    >
    > Dave
    >
     
    Joy, Jul 8, 2009
    #5
  6. headware

    Patrice Guest

    Your solution will likely be the simplest. In some cases you can also
    trigger a script based on an event based on perfmon or perhaps on an entry
    written in the windows log (try an admin group if you want to give a closer
    look at possible options).

    Generally I stay away of running something not directly related to the web
    site inside my web site. I prefer to use :
    - a windows service
    - or a scheduled application
    - or a SQL Server job
    for related background tasks...

    --
    Patrice

    "headware" <> a écrit dans le message de groupe de
    discussion :
    ...
    > It appears that if the worker process is recycled by IIS, that
    > Application_Start is not called again until the next request comes in.
    > Is there any way to get this to happen automatically right after the
    > process is recycled without relying on a request from a user?
    >
    > The basic story behind this is that we have a thread that is created
    > in Application_Start and it's supposed to run constantly over the life
    > of the application. The user does not want to set up the app pool so
    > that the worker process is never recycled. Is there any way around
    > this? We could create some kind of dummy client that requests a page
    > from the app every so often but I was hoping that there would be a
    > more elegant solution.
    >
    > Thanks,
    > Dave
     
    Patrice, Jul 8, 2009
    #6
  7. headware

    headware Guest

    On Jul 8, 8:22 am, "Patrice" <http://scribe-en.blogspot.com/> wrote:
    > Your solution will likely be the simplest. In some cases you can also
    > trigger a script based on an event based on perfmon or perhaps on an entry
    > written in the windows log (try an admin group if you want to give a closer
    > look at possible options).
    >
    > Generally I stay away of running something not directly related to the web
    > site inside my web site. I prefer to use :
    > - a windows service
    > - or a scheduled application
    > - or a SQL Server job
    > for related background tasks...
    >
    > --
    > Patrice
    >
    > "headware" <> a écrit dans le message de groupe de
    > discussion :
    > ...
    >
    > > It appears that if the worker process is recycled by IIS, that
    > > Application_Start is not called again until the next request comes in.
    > > Is there any way to get this to happen automatically right after the
    > > process is recycled without relying on a request from a user?

    >
    > > The basic story behind this is that we have a thread that is created
    > > in Application_Start and it's supposed to run constantly over the life
    > > of the application. The user does not want to set up the app pool so
    > > that the worker process is never recycled. Is there any way around
    > > this? We could create some kind of dummy client that requests a page
    > > from the app every so often but I was hoping that there would be a
    > > more elegant solution.

    >
    > > Thanks,
    > > Dave


    Thanks for the reply. We initially decided that a Windows service was
    not going to work because client didn't want one installed on their
    server. Otherwise, that's the solution we would have gone with from
    the beginning. I was hoping there would be some way to configure IIS
    or ASP.NET to wake the process back up immediately after it was
    recycled but I'm not hearing anybody say that.

    Dave
     
    headware, Jul 9, 2009
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Welman Jordan

    ASPX working process recycled, what will lost?

    Welman Jordan, Jan 2, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    342
    Welman Jordan
    Jan 5, 2004
  2. Henry Chen
    Replies:
    0
    Views:
    431
    Henry Chen
    Jun 10, 2004
  3. Weston Weems
    Replies:
    1
    Views:
    399
    Kevin Spencer
    Jan 4, 2005
  4. alex
    Replies:
    1
    Views:
    648
    Lau Lei Cheong
    Feb 4, 2005
  5. Navin Mishra

    How to get process id of hosting ASP.NET worker process ?

    Navin Mishra, Feb 7, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    432
    Navin Mishra
    Feb 7, 2006
Loading...

Share This Page