poidasmith / winrun4j

WinRun4J Java Application Launcher
http://winrun4j.sourceforge.net
212 stars 63 forks source link

Stopping service Error 109 #60

Open antoniobermuda opened 10 years ago

antoniobermuda commented 10 years ago

Hi, I'm using WinRun4J in scala application based on Akka. In one Actor i do blocking reading, and thus i cant stop this thread, so i must to cal System.exit(0), but when i do this, service stops with error 106.

Is it possible to clean stop service when using System.exit(0)?

neandrake commented 10 years ago

The title of this issue says error 109 but in your description you list 106 :) - which one are you seeing?

It sounds like what might be happening is that you're closing down the service prior to receiving the stop control signal. Or more particularly what is probably happening is that your service receives the stop signal, and you exit prior to WinRun4J reporting that the service is stopped. When you receive the stop control request you should spawn a new thread to terminate (perhaps with a small delay), allowing control to return to WinRun4J so it can call SetServiceStatus() which updates the Service Control Manager to know that your service is responding appropriately.