-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[Android][libs] Introduce GetLocalUtcOffset temporary fast result #74459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
a3f0e9f
a44084a
1edaeee
0712f57
96bf37f
582c359
9a2a8a2
f352b3a
f7dc8e9
32451c8
1a55a0c
61af7b7
50ff121
b1531b6
533ad1c
ef7729e
55fcccc
1cfc352
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -144,6 +144,7 @@ private static TimeZoneInfo GetLocalTimeZoneCore() | |
|
|
||
| private static TimeSpan? _localUtcOffset; | ||
| private static object _localUtcOffsetLock = new(); | ||
| private static Thread? _loadAndroidTZData; | ||
| // Shortcut for TimeZoneInfo.Local.GetUtcOffset | ||
| internal static TimeSpan GetLocalUtcOffset(DateTime dateTime, TimeZoneInfoOptions flags) | ||
| { | ||
|
|
@@ -153,19 +154,24 @@ internal static TimeSpan GetLocalUtcOffset(DateTime dateTime, TimeZoneInfoOption | |
| return cachedData.Local.GetUtcOffset(dateTime, flags, cachedData); | ||
| } | ||
|
|
||
| if (_localUtcOffset == null) | ||
| if (_localUtcOffset == null && _loadAndroidTZData == null) | ||
| { | ||
| lock (_localUtcOffsetLock) | ||
| { | ||
| if (_localUtcOffset == null) | ||
| if (_localUtcOffset != null) | ||
| { | ||
| Thread loadAndroidTZData = new Thread(() => { | ||
| CachedData cachedData = s_cachedData; | ||
| return cachedData.Local.GetUtcOffset(dateTime, flags, cachedData); | ||
| } | ||
| if (_loadAndroidTZData == null) | ||
| { | ||
| _loadAndroidTZData = new Thread(() => { | ||
| CachedData cachedData = s_cachedData; | ||
| _localUtcOffset = cachedData.Local.GetUtcOffset(dateTime, flags, cachedData); | ||
| Thread.Sleep(1000); | ||
|
||
| }); | ||
| loadAndroidTZData.IsBackground = true; | ||
| loadAndroidTZData.Start(); | ||
| Thread.Sleep(1000); | ||
| _loadAndroidTZData.IsBackground = true; | ||
| _loadAndroidTZData.Start(); | ||
mdh1418 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.