Skip to content

Commit 2759a04

Browse files
committed
Try to fix hang calling RequestAccessAsync
1 parent b7a5b86 commit 2759a04

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

src/LanguageDialog.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,31 +56,31 @@ private void okButton_Click(object sender, EventArgs e)
5656
int langIndex = languageNames.IndexOf((string)comboBox1.SelectedItem);
5757
string languageCode = Localization.languageCodes[langIndex];
5858

59-
// if (languageCode != Localization.currentLocale)
60-
// {
61-
// Localization.currentLocale = languageCode;
59+
if (languageCode != Localization.currentLocale)
60+
{
61+
Localization.currentLocale = languageCode;
6262

63-
// if (AppContext.notifyIcon == null) // Has UI been loaded yet?
64-
// {
65-
// Localization.LoadLocaleFromFile();
66-
// }
63+
if (AppContext.notifyIcon == null) // Has UI been loaded yet?
64+
{
65+
Localization.LoadLocaleFromFile();
66+
}
6767

68-
// JsonConfig.settings.language = languageCode;
68+
JsonConfig.settings.language = languageCode;
6969

70-
// if (AppContext.notifyIcon != null)
71-
// {
72-
// DialogResult result = MessageDialog.ShowQuestion(_("WinDynamicDesktop needs to restart for the " +
73-
// "language to change. Do you want to restart the app now?"), _("Question"));
70+
if (AppContext.notifyIcon != null)
71+
{
72+
DialogResult result = MessageDialog.ShowQuestion(_("WinDynamicDesktop needs to restart for the " +
73+
"language to change. Do you want to restart the app now?"), _("Question"));
7474

75-
// if (result == DialogResult.Yes)
76-
// {
77-
// JsonConfig.ReloadConfig();
78-
// }
79-
// }
80-
// }
75+
if (result == DialogResult.Yes)
76+
{
77+
JsonConfig.ReloadConfig();
78+
}
79+
}
80+
}
8181

8282
this.Close();
83-
Localization.SelectLanguage(false);
83+
//Localization.SelectLanguage(false);
8484
}
8585

8686
private void cancelButton_Click(object sender, EventArgs e)

src/UwpLocation.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ public static bool HasAccess()
2525

2626
try
2727
{
28-
hasAccess = Task.Run(() => UnsafeRequestAccess()).Result;
28+
var task = Task.Run(() => UnsafeRequestAccess());
29+
if (Task.WaitAny(task, Task.Delay(5000)) == 0)
30+
{
31+
hasAccess = task.Result;
32+
}
2933
}
3034
catch // Error when attempting to show UWP location prompt in WinForms app
3135
{
@@ -69,7 +73,8 @@ public static async Task<bool> UpdateGeoposition()
6973

7074
return true;
7175
}
72-
catch (Exception exc) {
76+
catch (Exception exc)
77+
{
7378
lastUpdateError = exc;
7479
}
7580

0 commit comments

Comments
 (0)