Skip to content

Commit

Permalink
Prevent exception by using TryOpenExisting for single instance handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Boddlnagg committed Mar 30, 2024
1 parent 5ba5b08 commit f8cf40d
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions WordsLive/Utils/WpfSingleInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ internal static void Make(string appName, bool uniquePerUser = true)
bool isSecondaryInstance = true;

EventWaitHandle eventWaitHandle = null;
try
{
eventWaitHandle = EventWaitHandle.OpenExisting(eventName);
}
catch
if (!EventWaitHandle.TryOpenExisting(eventName, out eventWaitHandle))
{
// This code only runs on the first instance.
isSecondaryInstance = false;
Expand Down

0 comments on commit f8cf40d

Please sign in to comment.