Skip to content

Commit 30cbc32

Browse files
committed
Launch updater code in a separate task
1 parent 4636311 commit 30cbc32

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

StarManager/MainWindow.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using Newtonsoft.Json;
1515
using System.Drawing.Imaging;
1616
using System.Drawing.Drawing2D;
17+
using System.Threading.Tasks;
1718

1819
namespace StarDisplay
1920
{
@@ -272,14 +273,21 @@ private void UpdateStars(object sender)
272273
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk);
273274
if (result == DialogResult.Yes)
274275
{
275-
try
276+
Task.Run(() =>
276277
{
277-
um.UpdateAndRestart();
278-
}
279-
catch (Exception)
280-
{
281-
Process.Start(um.DownloadPath());
282-
}
278+
try
279+
{
280+
um.UpdateAndRestart();
281+
SafeInvoke(() =>
282+
{
283+
Application.Restart();
284+
});
285+
}
286+
catch (Exception)
287+
{
288+
Process.Start(um.DownloadPath());
289+
}
290+
});
283291
}
284292
if (result == DialogResult.Cancel)
285293
{

StarManager/Managers/UpdateManager.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ public void UpdateAndRestart()
129129

130130
File.Move(filename, oldTempName);
131131
File.Move(newTempName, filename);
132-
133-
System.Windows.Forms.Application.Restart();
134132
}
135133

136134
public Version UpdateVersion()

0 commit comments

Comments
 (0)