I use DateTime.UtcNow.ToLongTimeString()
to get the current time string.
However it behaves weird, sometimes it returns time like 3:10:00
and sometimes like 03:10:00
(leading zero). Why this happens?
I set a culture on application startup
Thread.CurrentThread.CurrentCulture = new CultureInfo(...);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(...);
And the different result for the time string comes from a Task (from what I can see now). So I create a Task and .Wait()
for it to finish. Inside the task the time is converted to string differently.
UPDATE
For those who are interested, here is some helpful reading I found:
Is there a way of setting culture for a whole application? All current threads and new threads?
http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.defaultthreadcurrentculture.aspx