Services

T

Tomas Andersson

I have two questions regarding services.

First of.
Is there any problem with creating VB9 services running timer events om
Winxp?
I built a service App and it installs and runs but the timer events doesn´t
klick.

Lastly, how do I logon to another computer Win2003 Server and restart /
check status of a service.
 
T

Tomas Andersson

I tried both System.threading.timer and system.timers.timer and none seemed
to work



And I need to restart the service programmatically.

Here is the thing.

My program creates importfiles for another system. These files can have
multiple levels that has to be imported from the lowest level to the
highest. Therefore my program creates these imports and add them to a
database for temporary storage.

Another program then looks at the priority and dumps these files to a folder
where yet another program finds these files and imports them.

Problem is that this last step uses a little dodgy service that sometime
loses the connection to the importprogram, or rather the other way round.
Any who. The solution Is to restart the service so the connection goes up
again.



So when the middle program detects that there is imports cued in DB and a
already bumped importfile has not been touched for some time this should
restart the service



/Tomas



"Tom Shelton" <[email protected]> skrev i meddelandet
 
M

Mr. Arnold

Tomas Andersson said:
I tried both System.threading.timer and system.timers.timer and none seemed
to work

You must be doing something wrong.

And I need to restart the service programmatically.

Here is the thing.

My program creates importfiles for another system. These files can have
multiple levels that has to be imported from the lowest level to the
highest. Therefore my program creates these imports and add them to a
database for temporary storage.

Another program then looks at the priority and dumps these files to a
folder where yet another program finds these files and imports them.

Problem is that this last step uses a little dodgy service that sometime
loses the connection to the importprogram, or rather the other way round.
Any who. The solution Is to restart the service so the connection goes up
again.



So when the middle program detects that there is imports cued in DB and a
already bumped importfile has not been touched for some time this should
restart the service

You can use the Service Controller and stop or start a service running on
another machines. The programs would need to use an Admin account that's
active on both machines.

http://www.siccolo.com/Articles/CodeProject/Web_Method_To_Restart_NT/Web_Method_To_Restart_NT.html
 
P

Phill W.

Tomas said:
Is there any problem with creating VB9 services running timer events om
Winxp?

There's no inherent problem - I do it all the time.
I built a service App and it installs and runs but the timer events doesn´t
klick.

One possibility is that your Timer /is/ firing, but that the timer's
Elapsed() routine cannot be JIT-loaded because there's a referenced Type
or Assembly missing. The Framework probably throws an exception about
this, but I've never managed to find anywhere in /my/ code that I can
/catch/ it!

Because of this, I only use a Timer /once/ to get me out of the
"Call-and-Return" structure invoked by the Service Control Manager to
/start/ the Server; after that, I use Sleep calls within my "main" routine:

Overrides Sub OnStart()
TimerX.Start()
End Sub

Sub TimerX_Elapsed( ... ) Handles TimerX.Elapsed
TimerX.Stop()

Do While Not m_bShutdownRequested

Try
DoSomethingUseful()
Catch ex as Exception
' Log it, or whatever
' Don't let the Service Process die
End Try

For i as integer = 1 to 15
System.Threading.Thread.Sleep( 1000 )
Next

Loop

End Sub

HTH,
Phill W.
 

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