File tree 1 file changed +11
-4
lines changed
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,8 @@ public abstract class TimeZone
56
56
// Fields
57
57
static TimeZone currentTimeZone ;
58
58
59
+ [ NonSerialized ]
60
+ static object tz_lock = new object ( ) ;
59
61
[ NonSerialized ]
60
62
static long timezone_check ;
61
63
@@ -68,13 +70,18 @@ protected TimeZone ()
68
70
public static TimeZone CurrentTimeZone {
69
71
get {
70
72
long now = DateTime . GetNow ( ) ;
73
+ TimeZone tz ;
71
74
72
- if ( currentTimeZone == null || ( now - timezone_check ) > TimeSpan . TicksPerMinute ) {
73
- currentTimeZone = new CurrentSystemTimeZone ( now ) ;
74
- timezone_check = now ;
75
+ lock ( tz_lock ) {
76
+ if ( currentTimeZone == null || ( now - timezone_check ) > TimeSpan . TicksPerMinute ) {
77
+ currentTimeZone = new CurrentSystemTimeZone ( now ) ;
78
+ timezone_check = now ;
79
+ }
80
+
81
+ tz = currentTimeZone ;
75
82
}
76
83
77
- return currentTimeZone ;
84
+ return tz ;
78
85
}
79
86
}
80
87
You can’t perform that action at this time.
0 commit comments