@@ -8,6 +8,14 @@ namespace SourceGit.Models
88{
99 public class IpcChannel : IDisposable
1010 {
11+
12+ #if DEBUG
13+ private readonly string PROC_LOCK = "process.debug.lock" ;
14+ private readonly string IPC_NAME = "SourceGitIPCChannel.Debug" ;
15+ #else
16+ private readonly string PROC_LOCK = "process.lock" ;
17+ private readonly string IPC_NAME = "SourceGitIPCChannel" ;
18+ #endif
1119 public bool IsFirstInstance { get ; }
1220
1321 public event Action < string > MessageReceived ;
@@ -16,10 +24,11 @@ public IpcChannel()
1624 {
1725 try
1826 {
19- _singletonLock = File . Open ( Path . Combine ( Native . OS . DataDir , "process.lock" ) , FileMode . OpenOrCreate , FileAccess . ReadWrite , FileShare . None ) ;
27+ _singletonLock = File . Open ( Path . Combine ( Native . OS . DataDir , PROC_LOCK ) ,
28+ FileMode . OpenOrCreate , FileAccess . ReadWrite , FileShare . None ) ;
2029 IsFirstInstance = true ;
2130 _server = new NamedPipeServerStream (
22- "SourceGitIPCChannel" + Environment . UserName ,
31+ IPC_NAME + Environment . UserName ,
2332 PipeDirection . In ,
2433 - 1 ,
2534 PipeTransmissionMode . Byte ,
@@ -37,7 +46,7 @@ public void SendToFirstInstance(string cmd)
3746 {
3847 try
3948 {
40- using ( var client = new NamedPipeClientStream ( "." , "SourceGitIPCChannel" + Environment . UserName , PipeDirection . Out , PipeOptions . Asynchronous | PipeOptions . CurrentUserOnly ) )
49+ using ( var client = new NamedPipeClientStream ( "." , IPC_NAME + Environment . UserName , PipeDirection . Out , PipeOptions . Asynchronous | PipeOptions . CurrentUserOnly ) )
4150 {
4251 client . Connect ( 1000 ) ;
4352 if ( ! client . IsConnected )
@@ -93,8 +102,8 @@ private async void StartServer()
93102 }
94103 }
95104
96- private FileStream _singletonLock = null ;
97- private NamedPipeServerStream _server = null ;
98- private CancellationTokenSource _cancellationTokenSource = null ;
105+ private readonly FileStream _singletonLock = null ;
106+ private readonly NamedPipeServerStream _server = null ;
107+ private readonly CancellationTokenSource _cancellationTokenSource = null ;
99108 }
100109}
0 commit comments