T
Tino Donderwinkel
I have a Windows Forms application that I'm 'converting' into a Windows
Service.
In order for the service to stop, I have to wait for an object to change
it's state. In the windows forms application I have something like;
while (myobject.state != objectstate.finished) {
Application.DoEvents();
}
I also have a Callback function in the object, that is called when its state
changes to 'finished'.
In the equivalent Windows Service, I cannot use Application.DoEvents()
because it requires the System.Windows.Forms namespace.
I have tried Thread.Sleep(1000) or something, but doing that will stall
'everything'.
Any ideas how I can solve this in a Windows Service?
This code is in the "Stop()" method of the service; I need to wait for
either the Callback to happen or the state to change to 'finsihed' before
returning from the Stop().
Tino Donderwinkel
Exchange Server MVP
Service.
In order for the service to stop, I have to wait for an object to change
it's state. In the windows forms application I have something like;
while (myobject.state != objectstate.finished) {
Application.DoEvents();
}
I also have a Callback function in the object, that is called when its state
changes to 'finished'.
In the equivalent Windows Service, I cannot use Application.DoEvents()
because it requires the System.Windows.Forms namespace.
I have tried Thread.Sleep(1000) or something, but doing that will stall
'everything'.
Any ideas how I can solve this in a Windows Service?
This code is in the "Stop()" method of the service; I need to wait for
either the Callback to happen or the state to change to 'finsihed' before
returning from the Stop().
Tino Donderwinkel
Exchange Server MVP