Skip to content

Commit 70ba6c1

Browse files
committed
fix(update): fix update ui crashing.
Auto update still works. Fixes #1693
1 parent e863c16 commit 70ba6c1

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

SoundSwitch/Program.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ internal static class Program
4343

4444
[DllImport("user32.dll")]
4545
private static extern bool SetProcessDPIAware();
46-
46+
4747
[STAThread]
48-
private static async Task Main()
48+
private static void Main() => OldMain().GetAwaiter().GetResult();
49+
50+
private static async Task OldMain()
4951
{
5052
using var mainCts = new CancellationTokenSource();
5153
var sentryOptions = new SentryOptions

SoundSwitch/UI/Component/TrayIcon.cs

+3-6
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ public TrayIcon()
8383
_updateDownloadForm = new Lazy<UpdateDownloadForm>(() =>
8484
{
8585
UpdateDownloadForm form = null;
86-
_context.Send(_ =>
87-
{
88-
form = new UpdateDownloadForm();
89-
}, null);
86+
_context.Send(_ => { form = new UpdateDownloadForm(); }, null);
9087
return form;
9188
});
9289
//Localization
@@ -179,7 +176,7 @@ private void PopulateSettingsMenu()
179176
_settingsMenu.Items.Add(TrayIconStrings.playbackDevices, ResourcePlaybackDevicesBitmap,
180177
(sender, e) => { Process.Start(new ProcessStartInfo("control", "mmsys.cpl sounds")); });
181178
_settingsMenu.Items.Add(TrayIconStrings.volumeMixer, ResourceMixerBitmap,
182-
(sender, e) => { Process.Start(new ProcessStartInfo("sndvol.exe")); });
179+
(sender, e) => { Process.Start(new ProcessStartInfo("sndvol.exe")); });
183180
_settingsMenu.Items.Add(SettingsStrings.resetAudioDevices, Resources.resetAudioDevice.ToBitmap(),
184181
(sender, e) => { AudioSwitcher.Instance.ResetProcessDeviceConfiguration(); });
185182
_settingsMenu.Items.Add(TrayIconStrings.settings, ResourceSettingsSmallBitmap,
@@ -213,7 +210,7 @@ private void OnUpdateClick(object sender, EventArgs eventArgs)
213210

214211
StopAnimationIconUpdate();
215212
NotifyIcon.BalloonTipClicked -= OnUpdateClick;
216-
_updateDownloadForm.Value.DownloadRelease((AppRelease)_updateMenuItem.Tag);
213+
_context.Send(_ => { _updateDownloadForm.Value.DownloadRelease((AppRelease)_updateMenuItem.Tag); }, null);
217214
}
218215

219216
private void SetEventHandlers()

0 commit comments

Comments
 (0)