diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb
index 95b698d..129e739 100644
--- a/GBM/Forms/frmMain.vb
+++ b/GBM/Forms/frmMain.vb
@@ -1826,36 +1826,50 @@ Public Class frmMain
End Sub
Private Sub Main_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
+ Dim oMutex As New System.Threading.Mutex
+ Dim bNewInstance As Boolean
+
'Init
Try
- SetForm()
- VerifyGameDataPath()
- LoadAndVerify()
- If Not bInitFail Then
- VerifyCustomPathVariables()
+ oMutex = New System.Threading.Mutex(True, "GameBackupMonitor", bNewInstance)
- If oSettings.StartToTray And Not mgrCommon.IsUnix Then
- bShowToggle = False
- Me.Visible = False
- Me.ShowInTaskbar = False
- End If
+ 'Ensure only one instance is running
+ If Not bNewInstance Then
+ mgrCommon.ShowMessage(frmMain_ErrorAlreadyRunning, MsgBoxStyle.Exclamation)
+ ShutdownApp(False)
+ Else
+ SetForm()
+ VerifyGameDataPath()
+ LoadAndVerify()
+ If Not bInitFail Then
+ VerifyCustomPathVariables()
- If oSettings.MonitorOnStartup Then
- eCurrentStatus = eStatus.Stopped
- Else
- eCurrentStatus = eStatus.Running
- End If
+ If oSettings.StartToTray And Not mgrCommon.IsUnix Then
+ bShowToggle = False
+ Me.Visible = False
+ Me.ShowInTaskbar = False
+ End If
- HandleScan()
- CheckForNewBackups()
+ If oSettings.MonitorOnStartup Then
+ eCurrentStatus = eStatus.Stopped
+ Else
+ eCurrentStatus = eStatus.Running
+ End If
- 'Unix Handler
- If mgrCommon.IsUnix Then
- Me.MinimizeBox = True
- Else
- Me.gMonTray.Visible = True
+ HandleScan()
+ CheckForNewBackups()
+
+ 'Unix Handler
+ If mgrCommon.IsUnix Then
+ Me.MinimizeBox = True
+ Else
+ Me.gMonTray.Visible = True
+ End If
+
+ GC.KeepAlive(oMutex)
End If
End If
+
Catch ex As Exception
If mgrCommon.ShowMessage(frmMain_ErrorInitFailure, ex.Message, MsgBoxStyle.YesNo) = MsgBoxResult.No Then
bInitFail = True
diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb
index 05b6ea4..7c91d1e 100644
--- a/GBM/My Project/Resources.Designer.vb
+++ b/GBM/My Project/Resources.Designer.vb
@@ -2832,6 +2832,15 @@ Namespace My.Resources
End Get
End Property
+ '''
+ ''' Looks up a localized string similar to An instance of Game Backup Monitor is already running..
+ '''
+ Friend ReadOnly Property frmMain_ErrorAlreadyRunning() As String
+ Get
+ Return ResourceManager.GetString("frmMain_ErrorAlreadyRunning", resourceCulture)
+ End Get
+ End Property
+
'''
''' Looks up a localized string similar to GBM is running from a new location, the Windows startup entry has been updated..
'''
diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx
index b68b8d0..8ed7679 100644
--- a/GBM/My Project/Resources.resx
+++ b/GBM/My Project/Resources.resx
@@ -1945,4 +1945,7 @@
Enable session tracking
+
+ An instance of Game Backup Monitor is already running.
+
\ No newline at end of file