Saturday, April 22, 2006

Status watching thread in windows services.

I have a windows service program which needs to integrate with another vendor's program. The thing troubling me is that i cannot set up a good test environment with them. The only thing I can do is logging every error my program encounters.

Since it's running as a windows service, so it won't stop even it finds some errors, and the loop just continues running. I put this service on a client's machine, and it generates 2 GB log data in one day. It's pretty embarassing.

So, what I ends up is to create another status watching thread monitoring the log file it generates, if it finds out the log file size is exceeding the certain size, it will send a stop message to the ServieMain() thread, which will stop the service.
GISResearch

No comments: