Skip to content

Commit

Permalink
Adding proper exit code so the application doesn't stay active in the…
Browse files Browse the repository at this point in the history
… background
  • Loading branch information
André Ferreira committed Nov 12, 2016
1 parent 915d1dd commit 9cabfe9
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions mi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,32 @@ static void Main(string[] args)
Application.SetCompatibleTextRenderingDefault(false);
var ni = new NotifyIcon();


try
{
using (var pi = new ProcessIcon())
try
{
using (var pi = new ProcessIcon())
{
pi.Display();
Application.Run();
}
}
catch (Exception ex)
{
pi.Display();
Application.Run();
MessageBox.Show(ex.Message, "Program Terminated Unexpectedly",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
controllersManager.Abort();
scpBus.UnplugAll();
foreach (var device in Gamepads.Select(g => g.Device))
{
device.CloseDevice();
}
}
catch (Exception ex)
finally
{
MessageBox.Show(ex.Message, "Program Terminated Unexpectedly",
MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(0);
}
scpBus.UnplugAll();
}

private static void ManageControllers(ScpBus scpBus)
Expand Down

0 comments on commit 9cabfe9

Please sign in to comment.