system shutdown check from windows service

  • Thread starter Thread starter Myo Zaw
  • Start date Start date
M

Myo Zaw

hi,
i have a windows service that check to the external web site
httpwebresponse and save the result into log text file. and, my problem is
when i shut down my system, i also would like to save the time that i shut
down my system into that log file. but, i don't know how to do that. so,
please give me some idea or suggestion on that.

thanks,
myo zaw
 
Myo said:
hi,
i have a windows service that check to the external web site
httpwebresponse and save the result into log text file. and, my problem is
when i shut down my system, i also would like to save the time that i shut
down my system into that log file. but, i don't know how to do that. so,
please give me some idea or suggestion on that.

thanks,
myo zaw

The simliest thing would be to use the onshutdown event in the service
to write out your log file. This won't tell you if the system is
shutting down or not so you'll get both the service stopping because of
system shutdown or user stopping the service.

Chris
 
Myo Zaw said:
hi,
i have a windows service that check to the external web site
httpwebresponse and save the result into log text file. and, my problem is
when i shut down my system, i also would like to save the time that i shut
down my system into that log file. but, i don't know how to do that. so,
please give me some idea or suggestion on that.

thanks,
myo zaw
Override the OnShutDown event handler...
Check MSDN for ServiceBase.OnShutDown for more info.


Willy.
 
thanks,
it went fine. but, one more question, i don't know why i can't access
to app.config file in my windows service. it worked fine in win32
application. i already tested with the same situation but, in my service,
the call from configurationmanager showed me that null value was return. any
idea about that?

thanks again,
myo zaw
 

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