I wrote a c# service that register to systemevent.Timechange() with function that call OntimeChange() (as mentioned in the MSDN http://msdn.microsoft.com/en-us/library/microsoft.win32.systemevents.aspx)
Running this code in visual studio all works fine (In debug or release mode),
but when I run the service I saw that the function OntimeChange() isn’t called (I added prints to the log in this function, and I saw that nothing printed to the log)
can someone help?
In the remarks section of the SystemEvents.TimeChanged event you can read the following text:
So in short, you need a hidden form to receive these events in a service.
See the Example 2 listed on the page you linked in your question on how to do that.