Home All Groups Group Topic Archive Search About

ASP Windows Service or Console based application

Author
16 Dec 2005 5:23 PM
Stephen
Hi all,
I am confused as to what kind of application to develop. I have to create an
application thats like a "Engine" which continously monitors a DB or
whatever. It has to work even if the user logoff as this engine feeds some
other application.
I tried creating a Windows service that runs continously but the status
shows "Starting" and i cant "Stop" or "Pause" and was suggested by one
BravesCharm that "Status does not change as the service never notifies the
SCM that everything started OK" which makes sense.
Is there a way for windows service to start some other application? is yes
then how can i stop it from this windows service?

Please do give me suggestions on how to achieve this.

Thanks,
Stephen

Author
16 Dec 2005 6:13 PM
Alvin Bruney - ASP.NET MVP
build a windows service application to monitor the process - these are
called watch dog applications. You don't need to programmatically build a
stop or pause routine into the application because that type of
functionality is typically handled by the windows control manager.

A console based application is less reliable because it isnt automatically
started when windows restarts

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



Show quote
"Stephen" <stephen***@hotmail.com> wrote in message
news:ecATjVmAGHA.3804@TK2MSFTNGP14.phx.gbl...
> Hi all,
> I am confused as to what kind of application to develop. I have to create
an
> application thats like a "Engine" which continously monitors a DB or
> whatever. It has to work even if the user logoff as this engine feeds some
> other application.
> I tried creating a Windows service that runs continously but the status
> shows "Starting" and i cant "Stop" or "Pause" and was suggested by one
> BravesCharm that "Status does not change as the service never notifies the
> SCM that everything started OK" which makes sense.
> Is there a way for windows service to start some other application? is yes
> then how can i stop it from this windows service?
>
> Please do give me suggestions on how to achieve this.
>
> Thanks,
> Stephen
>
>
Author
16 Dec 2005 7:32 PM
Stephen
Thanks Alvin,
Question:
How do I stop or Pause the service? as the SCM status is always "Starting"
and "Stop" and "Pause" is never enabled.

Here's and eg of what I have experimented with:
1. Created a Windows Service and have used "OnStart" and "OnStop"
2. OnStart (Just for kicks) insert records into a testDB until conditions
match
3. OnStop delete all records from testDB.

Problem:
OnStart starts the service and contiunues forever... the condition does not
set itself to "Started", so the only way I can stop is to kill the process

Any suggestions,
Thanks again,
Stephen

Show quote
"Alvin Bruney - ASP.NET MVP" <www.lulu.com/owc> wrote in message
news:On6Q2xmAGHA.1028@TK2MSFTNGP11.phx.gbl...
> build a windows service application to monitor the process - these are
> called watch dog applications. You don't need to programmatically build a
> stop or pause routine into the application because that type of
> functionality is typically handled by the windows control manager.
>
> A console based application is less reliable because it isnt automatically
> started when windows restarts
>
> --
> Regards,
> Alvin Bruney [MVP ASP.NET]
>
> [Shameless Author plug]
> The Microsoft Office Web Components Black Book with .NET
> Now Available @ www.lulu.com/owc
> Forth-coming VSTO.NET - Wrox/Wiley 2006
> -------------------------------------------------------
>
>
>
> "Stephen" <stephen***@hotmail.com> wrote in message
> news:ecATjVmAGHA.3804@TK2MSFTNGP14.phx.gbl...
> > Hi all,
> > I am confused as to what kind of application to develop. I have to
create
> an
> > application thats like a "Engine" which continously monitors a DB or
> > whatever. It has to work even if the user logoff as this engine feeds
some
> > other application.
> > I tried creating a Windows service that runs continously but the status
> > shows "Starting" and i cant "Stop" or "Pause" and was suggested by one
> > BravesCharm that "Status does not change as the service never notifies
the
> > SCM that everything started OK" which makes sense.
> > Is there a way for windows service to start some other application? is
yes
> > then how can i stop it from this windows service?
> >
> > Please do give me suggestions on how to achieve this.
> >
> > Thanks,
> > Stephen
> >
> >
>
>
Author
17 Dec 2005 8:06 PM
Norman Yuan
The problem is that you do something in OnStart() of the Windows service and
the something keppes going on until some conditions matched. So, until the
conditions matched, the windows service will never be fully started (i,e.
not able to provide service).

According to your previous post, I think you are using Windows Service in a
wrong way. If you want a windows service do something, you do it AFTER the
service is started. In OnStart() you do initializing (i.e, prepare the
Windows service for the job you want it to do). For example, it the Win
Service is used for access data in database, you do not put the main data
access process in OnStart(), but you can write some code in OnStart() to get
database access settings, such as read ConnectionString from config. file or
from registry. Of cource, the logic in OnStart() can be more complecated
than that. Then, you must handle all possible exceptions in order for the
service can be started, and you also have to have a way to deal situation
like, if particaular initialization in OnStart() fails and the service
started anyway, what is the impact on the job you want the service to do...

The other thing you need to remember is, Wndows Service itself does nothing.
It provides a hosting environment for certain objects to run inside it. Most
..NET books use FileWatcher as the object hosted by a Windows Service.
Typically, you can host a Remoting object in Windows Service to do what you
want (accessing database...).


Show quote
"Stephen" <stephen***@hotmail.com> wrote in message
news:OAKC6dnAGHA.1288@TK2MSFTNGP09.phx.gbl...
> Thanks Alvin,
> Question:
> How do I stop or Pause the service? as the SCM status is always "Starting"
> and "Stop" and "Pause" is never enabled.
>
> Here's and eg of what I have experimented with:
> 1. Created a Windows Service and have used "OnStart" and "OnStop"
> 2. OnStart (Just for kicks) insert records into a testDB until conditions
> match
> 3. OnStop delete all records from testDB.
>
> Problem:
> OnStart starts the service and contiunues forever... the condition does
> not
> set itself to "Started", so the only way I can stop is to kill the process
>
> Any suggestions,
> Thanks again,
> Stephen
>
> "Alvin Bruney - ASP.NET MVP" <www.lulu.com/owc> wrote in message
> news:On6Q2xmAGHA.1028@TK2MSFTNGP11.phx.gbl...
>> build a windows service application to monitor the process - these are
>> called watch dog applications. You don't need to programmatically build a
>> stop or pause routine into the application because that type of
>> functionality is typically handled by the windows control manager.
>>
>> A console based application is less reliable because it isnt
>> automatically
>> started when windows restarts
>>
>> --
>> Regards,
>> Alvin Bruney [MVP ASP.NET]
>>
>> [Shameless Author plug]
>> The Microsoft Office Web Components Black Book with .NET
>> Now Available @ www.lulu.com/owc
>> Forth-coming VSTO.NET - Wrox/Wiley 2006
>> -------------------------------------------------------
>>
>>
>>
>> "Stephen" <stephen***@hotmail.com> wrote in message
>> news:ecATjVmAGHA.3804@TK2MSFTNGP14.phx.gbl...
>> > Hi all,
>> > I am confused as to what kind of application to develop. I have to
> create
>> an
>> > application thats like a "Engine" which continously monitors a DB or
>> > whatever. It has to work even if the user logoff as this engine feeds
> some
>> > other application.
>> > I tried creating a Windows service that runs continously but the status
>> > shows "Starting" and i cant "Stop" or "Pause" and was suggested by one
>> > BravesCharm that "Status does not change as the service never notifies
> the
>> > SCM that everything started OK" which makes sense.
>> > Is there a way for windows service to start some other application? is
> yes
>> > then how can i stop it from this windows service?
>> >
>> > Please do give me suggestions on how to achieve this.
>> >
>> > Thanks,
>> > Stephen
>> >
>> >
>>
>>
>
>
Author
19 Dec 2005 4:19 PM
Stephen
Thanks Yuan,
it makes sense.
Stephen


Show quote
"Norman Yuan" <NotR***@NotReal.not> wrote in message
news:uGUArU0AGHA.3984@TK2MSFTNGP14.phx.gbl...
> The problem is that you do something in OnStart() of the Windows service
and
> the something keppes going on until some conditions matched. So, until the
> conditions matched, the windows service will never be fully started (i,e.
> not able to provide service).
>
> According to your previous post, I think you are using Windows Service in
a
> wrong way. If you want a windows service do something, you do it AFTER the
> service is started. In OnStart() you do initializing (i.e, prepare the
> Windows service for the job you want it to do). For example, it the Win
> Service is used for access data in database, you do not put the main data
> access process in OnStart(), but you can write some code in OnStart() to
get
> database access settings, such as read ConnectionString from config. file
or
> from registry. Of cource, the logic in OnStart() can be more complecated
> than that. Then, you must handle all possible exceptions in order for the
> service can be started, and you also have to have a way to deal situation
> like, if particaular initialization in OnStart() fails and the service
> started anyway, what is the impact on the job you want the service to
do...
>
> The other thing you need to remember is, Wndows Service itself does
nothing.
> It provides a hosting environment for certain objects to run inside it.
Most
> .NET books use FileWatcher as the object hosted by a Windows Service.
> Typically, you can host a Remoting object in Windows Service to do what
you
> want (accessing database...).
>
>
> "Stephen" <stephen***@hotmail.com> wrote in message
> news:OAKC6dnAGHA.1288@TK2MSFTNGP09.phx.gbl...
> > Thanks Alvin,
> > Question:
> > How do I stop or Pause the service? as the SCM status is always
"Starting"
> > and "Stop" and "Pause" is never enabled.
> >
> > Here's and eg of what I have experimented with:
> > 1. Created a Windows Service and have used "OnStart" and "OnStop"
> > 2. OnStart (Just for kicks) insert records into a testDB until
conditions
> > match
> > 3. OnStop delete all records from testDB.
> >
> > Problem:
> > OnStart starts the service and contiunues forever... the condition does
> > not
> > set itself to "Started", so the only way I can stop is to kill the
process
> >
> > Any suggestions,
> > Thanks again,
> > Stephen
> >
> > "Alvin Bruney - ASP.NET MVP" <www.lulu.com/owc> wrote in message
> > news:On6Q2xmAGHA.1028@TK2MSFTNGP11.phx.gbl...
> >> build a windows service application to monitor the process - these are
> >> called watch dog applications. You don't need to programmatically build
a
> >> stop or pause routine into the application because that type of
> >> functionality is typically handled by the windows control manager.
> >>
> >> A console based application is less reliable because it isnt
> >> automatically
> >> started when windows restarts
> >>
> >> --
> >> Regards,
> >> Alvin Bruney [MVP ASP.NET]
> >>
> >> [Shameless Author plug]
> >> The Microsoft Office Web Components Black Book with .NET
> >> Now Available @ www.lulu.com/owc
> >> Forth-coming VSTO.NET - Wrox/Wiley 2006
> >> -------------------------------------------------------
> >>
> >>
> >>
> >> "Stephen" <stephen***@hotmail.com> wrote in message
> >> news:ecATjVmAGHA.3804@TK2MSFTNGP14.phx.gbl...
> >> > Hi all,
> >> > I am confused as to what kind of application to develop. I have to
> > create
> >> an
> >> > application thats like a "Engine" which continously monitors a DB or
> >> > whatever. It has to work even if the user logoff as this engine feeds
> > some
> >> > other application.
> >> > I tried creating a Windows service that runs continously but the
status
> >> > shows "Starting" and i cant "Stop" or "Pause" and was suggested by
one
> >> > BravesCharm that "Status does not change as the service never
notifies
> > the
> >> > SCM that everything started OK" which makes sense.
> >> > Is there a way for windows service to start some other application?
is
> > yes
> >> > then how can i stop it from this windows service?
> >> >
> >> > Please do give me suggestions on how to achieve this.
> >> >
> >> > Thanks,
> >> > Stephen
> >> >
> >> >
> >>
> >>
> >
> >
>
>
Author
16 Dec 2005 9:24 PM
Kevin Spencer
I tend to build business classes that can be plugged into any kind of
interface, be it a Console app, Windows Service, or Windows form. You never
know when you may need to extend it. And besides, building a simple Windows
Form for testing is much easier than debugging a Windows Service. But I do
agree with Alvin that ultimately, you should plug it into a Windows Service.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

Show quote
"Alvin Bruney - ASP.NET MVP" <www.lulu.com/owc> wrote in message
news:On6Q2xmAGHA.1028@TK2MSFTNGP11.phx.gbl...
> build a windows service application to monitor the process - these are
> called watch dog applications. You don't need to programmatically build a
> stop or pause routine into the application because that type of
> functionality is typically handled by the windows control manager.
>
> A console based application is less reliable because it isnt automatically
> started when windows restarts
>
> --
> Regards,
> Alvin Bruney [MVP ASP.NET]
>
> [Shameless Author plug]
> The Microsoft Office Web Components Black Book with .NET
> Now Available @ www.lulu.com/owc
> Forth-coming VSTO.NET - Wrox/Wiley 2006
> -------------------------------------------------------
>
>
>
> "Stephen" <stephen***@hotmail.com> wrote in message
> news:ecATjVmAGHA.3804@TK2MSFTNGP14.phx.gbl...
>> Hi all,
>> I am confused as to what kind of application to develop. I have to create
> an
>> application thats like a "Engine" which continously monitors a DB or
>> whatever. It has to work even if the user logoff as this engine feeds
>> some
>> other application.
>> I tried creating a Windows service that runs continously but the status
>> shows "Starting" and i cant "Stop" or "Pause" and was suggested by one
>> BravesCharm that "Status does not change as the service never notifies
>> the
>> SCM that everything started OK" which makes sense.
>> Is there a way for windows service to start some other application? is
>> yes
>> then how can i stop it from this windows service?
>>
>> Please do give me suggestions on how to achieve this.
>>
>> Thanks,
>> Stephen
>>
>>
>
>

AddThis Social Bookmark Button