1
0
mirror of https://github.com/chylex/Backup-Essentials.git synced 2025-08-04 15:59:07 +02:00

Check for InvalidOperationException when working with processes

This commit is contained in:
chylex 2015-05-07 00:25:56 +02:00
parent d3b72b0dad
commit 52270283ab

View File

@ -77,7 +77,13 @@ namespace BackupEssentials{
/// Runs the program without any special settings. Checks for already running process of the program, if there is one it moves it to foreground, if not it shows a new window.
/// </summary>
private void RunMainWindow(){
Process[] running = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location));
Process[] running;
try{
running = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location));
}catch(InvalidOperationException e){
running = new Process[0];
}
if (running.Length > 1){
int myId = Process.GetCurrentProcess().Id;