Call function when system time changed

I'm reading the Microsoft SystemEvents.TimeChanged and I'm having trouble understanding how to link my own function to call when the system time changes.
7 Replies
Omnissiah
Omnissiah•2mo ago
TimeChanged is an event, so you have to += it SystemEvents.TimeChanged += YourMethod; and remember to -= it when the program gets closed
jcotton42
jcotton42•2mo ago
Doesn’t matter really for app close time.
🌸 morgan period 🌸
The problem is my program isn't detecting SystemEvents? Is that a library I import?
jcotton42
jcotton42•2mo ago
SystemEvents Class (Microsoft.Win32)
Provides access to system event notifications. This class cannot be inherited.
jcotton42
jcotton42•2mo ago
You may need a -windows TFM for it. Eg net8.0-windows
canton7
canton7•2mo ago
(that's in the <TargetFramework> in your .csproj)
jcotton42
jcotton42•2mo ago
I wonder where you set a windows tfm in the VS GUI.
Want results from more Discord servers?
Add your server