1

I'm trying to set the timezone for an aplication that is supposed to run in .net compact framework and i'm getting a little bit o trouble to get it right.

I want to set it to GMT Standard Time but for some reason i keep getting the Monrovia, Reyqjavik Timezone:

Here is my code (Im using Opennet class):

Dim TZC As New TimeZoneCollection

TZC.Initialize(0)

For Each tzi As TimeZoneInformation In TZC

    If tzi.StandardName = "GMT Standard Time" Then
        Application.DoEvents()
        DateTimeHelper.SetTimeZoneInformation(tzi)
        Exit For
    End If

Next

For some reason it keeps setting it to Monrovia instead of London Timezone

Can anyone help? Thanks!

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
  • 1
    Why do you call `Application.DoEvents()`? Seems unnecessary here. Does it help if you remove it? – Matt Johnson-Pint Jun 28 '16 at 04:04
  • Hello Matt, I use the application.doevents just to give priority to the DateTimeHelper.SetTimeZoneInformation(tzi) function, i've tried to remove it but the problem remains. – Nuno Domingos Jun 29 '16 at 10:41
  • @NunoDomingos Using `Application.DoEvents()` does not give priority - it handles pending events that have _nothing to do_ with the code in which it is called. I don't think it matters to what timezone is being set in this situation, but you really should remove it unless you have a (rare) valid reason to use it. – C.Evenhuis Jul 01 '16 at 14:59
  • Possible duplicate of [.NET CF 3.5 SetTimeZoneInformation problem](http://stackoverflow.com/questions/5540266/net-cf-3-5-settimezoneinformation-problem) – C.Evenhuis Jul 01 '16 at 17:20
  • @C.Evenhuis Thank you for the explanation, i aprecciate it – Nuno Domingos Jul 06 '16 at 16:58
  • @C.Evenhuis While I agree with you that the two questions are similar, and personally I can translate from C# to VB.NET (or back) easily, [it might not be acceptable to try to mark a vb.net question as a dupe of a C# question.](https://meta.stackoverflow.com/questions/348770/cleanup-the-mis-tagging-between-c-and-vb-net) – jrh May 11 '17 at 14:55
  • @jrh I think in this case language doesn't matter as the problem is the same, and code is only used to illustrate the usage of the API. But that's just my opinion, and you do have a point. – C.Evenhuis May 11 '17 at 18:04
  • @C.Evenhuis I agree with you on that one; just passing on the message. – jrh May 11 '17 at 18:24

0 Answers0