Browse Source

Add relative path logic to new SingleInstance code

pull/3212/head
Christoph Wille 2 years ago
parent
commit
5fa25a606c
  1. 12
      ILSpy/AppEnv/SingleInstance.cs

12
ILSpy/AppEnv/SingleInstance.cs

@ -19,6 +19,7 @@ namespace Medo.Application;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO.Pipes; using System.IO.Pipes;
using System.Linq;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security.Cryptography; using System.Security.Cryptography;
@ -27,6 +28,8 @@ using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using System.Threading; using System.Threading;
using ICSharpCode.ILSpy.AppEnv;
/// <summary> /// <summary>
/// Handles detection and communication of programs multiple instances. /// Handles detection and communication of programs multiple instances.
/// This class is thread safe. /// This class is thread safe.
@ -49,6 +52,13 @@ public static class SingleInstance
return Attach(false); return Attach(false);
} }
private static string[] GetILSpyCommandLineArgs()
{
var cmdArgs = Environment.GetCommandLineArgs().Skip(1);
cmdArgs = cmdArgs.Select(CommandLineTools.FullyQualifyPath);
return cmdArgs.ToArray();
}
/// <summary> /// <summary>
/// Returns true if this application is not already started. /// Returns true if this application is not already started.
/// Another instance is contacted via named pipe. /// Another instance is contacted via named pipe.
@ -67,7 +77,7 @@ public static class SingleInstance
{ //we need to contact previous instance { //we need to contact previous instance
var contentObject = new SingleInstanceArguments() { var contentObject = new SingleInstanceArguments() {
CommandLine = Environment.CommandLine, CommandLine = Environment.CommandLine,
CommandLineArgs = Environment.GetCommandLineArgs(), CommandLineArgs = GetILSpyCommandLineArgs(),
}; };
var contentBytes = JsonSerializer.SerializeToUtf8Bytes(contentObject); var contentBytes = JsonSerializer.SerializeToUtf8Bytes(contentObject);
using var clientPipe = new NamedPipeClientStream(".", using var clientPipe = new NamedPipeClientStream(".",

Loading…
Cancel
Save