Controlled Failure Of a Windows Service

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to make my service fail so that I can utilise the recovery settings in
the service config screen.

The recovery settings should let me either restart the service, run a
program or restart the computer, however, my VB.Net services have never
failed!

Is there a way I can programatically make them fail?

Thanks.
 
m00nm0nkey said:
I need to make my service fail so that I can utilise the recovery settings in
the service config screen.

The recovery settings should let me either restart the service, run a
program or restart the computer, however, my VB.Net services have never
failed!

Is there a way I can programatically make them fail?

Thanks.

Run the Stop() method.
 
What, like this?

Private Sub tmrScheduler_Elapsed(ByVal sender As System.Object, ByVal e As
System.Timers.ElapsedEventArgs) Handles tmrScheduler.Elapsed

If gblnSomethingBadIsHappening Then

OnStop()

Else

tmrScheduler.Stop()
tmrScheduler.Enabled = False

SchedulerTimerRespond()

tmrScheduler.Enabled = True
tmrScheduler.Start()

End If

End Sub

??
 

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

Back
Top