Click here to Skip to main content
15,889,876 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to create a service which note the time of OS in OnStart event and save that start time and end time in OnShutDown event. But onShutDown() event is not firing. Same code is running in OnStop event.
VB
Me.ServiceProcessInstaller1.Account =System.ServiceProcess.ServiceAccount.LocalSystem
Me.ServiceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic

Posted
Comments
Sergey Alexandrovich Kryukov 25-Feb-13 17:05pm    
How you know that the event is not invoked?! You need to log it event using event log to be sure...
—SA

1 solution

Use System.Diagnostics.EventLog:
http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx[^].

This is the ultimate correct way to figure out if something is invoked or not.

—SA
 
Share this answer
 
Comments
Dinesh Ambaliya 26-Feb-13 1:42am    
In stop event, log entry is writes but same code in onshutdown event I had copy pasted then Installed service using command prompt. After starting the service I rebooted my system but not working
Sergey Alexandrovich Kryukov 26-Feb-13 1:45am    
Sorry, your comment is hard to understand. If you put appropriate punctuation and casing, I'll probably will be able to understand it... thank you.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900