0

In my winforms application, I have to display a list of events (like buttons' clicks) with the time of each of them. The time format has to be the same as Windows regional settings. So I'm using DateTimeoffset.ToLocalTime().ToString() for that which is working perfectly.

If I change Windows regional settings (time zone or format) while the application is running, the time is still displayed on the old format. As a workaround, I have to restart the application so it will grab the new regional settings.

Is there a way to get these settings on the fly?

Mhd
  • 2,778
  • 5
  • 22
  • 59
  • Possible duplicate of [How to receive event when user changes system's culture](https://stackoverflow.com/questions/4711555/how-to-receive-event-when-user-changes-systems-culture) – DonBoitnott Jun 30 '17 at 13:59

1 Answers1

-1

try calling this:

Thread.CurrentThread.CurrentCulture.ClearCachedData()

and then retrying your local time call

Jamal H
  • 934
  • 7
  • 23
  • 1
    When would he need to call it? – Rand Random Jun 30 '17 at 13:38
  • That works. But clearing the cache for each event seems not a good idea – Mhd Jun 30 '17 at 13:56
  • @Mhd take a look at this link: https://stackoverflow.com/questions/4711555/how-to-receive-event-when-user-changes-systems-culture If that event fires for changing the time, then clear the cache – Jamal H Jun 30 '17 at 13:58