@@ -8,6 +8,14 @@ namespace SourceGit.Models
8
8
{
9
9
public class IpcChannel : IDisposable
10
10
{
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
11
19
public bool IsFirstInstance { get ; }
12
20
13
21
public event Action < string > MessageReceived ;
@@ -16,10 +24,11 @@ public IpcChannel()
16
24
{
17
25
try
18
26
{
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 ) ;
20
29
IsFirstInstance = true ;
21
30
_server = new NamedPipeServerStream (
22
- "SourceGitIPCChannel" + Environment . UserName ,
31
+ IPC_NAME + Environment . UserName ,
23
32
PipeDirection . In ,
24
33
- 1 ,
25
34
PipeTransmissionMode . Byte ,
@@ -37,7 +46,7 @@ public void SendToFirstInstance(string cmd)
37
46
{
38
47
try
39
48
{
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 ) )
41
50
{
42
51
client . Connect ( 1000 ) ;
43
52
if ( ! client . IsConnected )
@@ -93,8 +102,8 @@ private async void StartServer()
93
102
}
94
103
}
95
104
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 ;
99
108
}
100
109
}
0 commit comments