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

??
 
Back
Top