A windows service question

G

Guest

Hi;

I have developed a VB.net app in a module that queries a database, loads the
data into several arrays and then loops through the array. It then compares
time data stored in the array with the current system time. If there is a
match a program is then started. The apps purpose is be like the windows task
scheduler. And I want
to run it as service because it will run continuosly.

I can't seen to find an example of where an app like this is made a service.
Most
of the examples of candidates for services a like a special backup routine
or to
monitor a specific process.

So could I run my app as a service ?

If so do I transfer my code which now exists in the main() sub and a
function into
the service class of a service project ? Or can I call my module from the
OnStart Sub ?

Thanks for any insights,
 
M

Mike Lowery

I don't see why your app can't run as a service, so long as you design it
properly. You'll also have to make sure it runs under the proper Windows
account to access external data (like your database.)

Have a look at this program I wrote that runs as a Windows service:
http://spamgrinderprox.sourceforge.net/
 
G

Guest

Hi;

After a little VS documentation research could this statement be all that is
needed to start my app?

Sub onStart()
Process.start("exe to start") ?????????????
End sub

Is this the correct way to sstart an app in service ?

Thanks,
 
B

Brian Gideon

Gordon,

No, that's not the right way. You're right about needing place code in
the OnStart method though. What you need to put there should get
everything going. Sometimes that is as simple as starting a timer and
sometimes it may require starting a new thread. In your case it sounds
like kicking off a timer will work well. In the timer event you'll use
the code you already have to query the database, etc. and then kick the
task off with Process.Start.

Brian
 
G

Guest

Hi;

My routine seems to be working OK with this line :

Sub onStart()
Process.start("exe to start") ?????????????
End sub

The exe that is called functions much like a timer in that it compares a
datetime value to Now() and responds to a match of those times.

Thanks
 

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

Top