Application_Start - does it run all the time?

E

Eric

Simple stupid question. Web application in VS2005 - I want to
run a thread that is active all the time as long as pc stays on.
Is it possible in ASP.NET? Is the instance of web application
destroyed when the client exits a web page? Or it runs continuously.
Application_Start event fires 1 time or every time for clients?
Maybe it's better to run a separate windows app and talk to page.
Thanks for helping.

Eric
 
J

Juan T. Llibre

re:
Is the instance of web application destroyed when the client exits a web page?

Nope.
Application_Start runs once every time the application is started.

re:
I want to run a thread that is active all the time as long as pc stays on.

Try writing a Windows Service.
 
M

Mark Rae

Simple stupid question. Web application in VS2005 - I want to
run a thread that is active all the time as long as pc stays on.
Is it possible in ASP.NET?

Pretty much anything is possible if you put your mind to it, but ASP.NET is
not the right technology for what you want here...
Is the instance of web application destroyed when the client exits a web
page? Or it runs continuously.

No - a web application starts when its first session is initiated and stops
when its last session is torn down - exiting a web page will not have any
effect on the Session or Application objects unless that web page is
specifically written that way...
Application_Start event fires 1 time or every time for clients?

No - the Application_Start event fires when the application first starts.
Maybe it's better to run a separate windows app and talk to page.

Yes - specifically, a Windows service.
 
U

Ufit

------------------- 8< ~~~~~~~~~
No - the Application_Start event fires when the application first starts.


Yes - specifically, a Windows service.

What is the advantage of using windows service instead a regular win. application?
Are there any performance issues? My thread will have a lot of workload - a big lot.
I don't even know the physical limits on PC for number of concurent threads.
The Windows Service can be convenient but rough to handle and debug.
What do you suggest?
Thank you for advices.

Eric
 
D

Damien

Ufit said:
------------------- 8< ~~~~~~~~~


What is the advantage of using windows service instead a regular win. application?
Services are running (assuming they're set to start automatically) from
the moment the machine starts until it shuts down. A windows app will
only run once someone logs on (if it's in the startup menu), and will
stop running when that person logs out. Or if you're using TS/Fast User
Switching, you might have multiple copies of your windows app trying to
run.
Are there any performance issues? My thread will have a lot of workload - a big lot.
I don't even know the physical limits on PC for number of concurent threads.
The Windows Service can be convenient but rough to handle and debug.
My normal way of developing services is to write a class library that
has a class that defines Start/Stop/Pause/Continue/Shutdown functions.
My Service exe is just a thin wrapper around this class library. But I
also have a windows forms application that has buttons that link to
these functions - so when I'm debugging, I use the windows application
to simulate running the service, and then I just deploy the service exe
and the class library into production.

The only problem I've encountered with the above method of debugging
services is that most of the services I've written are intended to run
under LocalService or NetworkService, so debugging it through windows
forms (where it's running under my account) can lead to me missing some
permissions issues.

If you're looking to debug behaviour that isn't part of the
startup/shutdown of the service, but is instead part of the normal
operation of the service, then you can always start a debug build of
the service normally and then attach the debugger to it, before doing
whatever it is that triggers behaviour in your service (e.g. a remoting
call, a MSMQ message arriving, etc)

Damien
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top