Skip to content

feat: support launch a debug sourcegit #1642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/Models/IpcChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ namespace SourceGit.Models
{
public class IpcChannel : IDisposable
{

#if DEBUG
private readonly string PROC_LOCK = "process.debug.lock";
private readonly string IPC_NAME = "SourceGitIPCChannel.Debug";
#else
private readonly string PROC_LOCK = "process.lock";
private readonly string IPC_NAME = "SourceGitIPCChannel";
#endif
public bool IsFirstInstance { get; }

public event Action<string> MessageReceived;
Expand All @@ -16,10 +24,11 @@ public IpcChannel()
{
try
{
_singletonLock = File.Open(Path.Combine(Native.OS.DataDir, "process.lock"), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
_singletonLock = File.Open(Path.Combine(Native.OS.DataDir, PROC_LOCK),
FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
IsFirstInstance = true;
_server = new NamedPipeServerStream(
"SourceGitIPCChannel" + Environment.UserName,
IPC_NAME + Environment.UserName,
PipeDirection.In,
-1,
PipeTransmissionMode.Byte,
Expand All @@ -37,7 +46,7 @@ public void SendToFirstInstance(string cmd)
{
try
{
using (var client = new NamedPipeClientStream(".", "SourceGitIPCChannel" + Environment.UserName, PipeDirection.Out, PipeOptions.Asynchronous | PipeOptions.CurrentUserOnly))
using (var client = new NamedPipeClientStream(".", IPC_NAME + Environment.UserName, PipeDirection.Out, PipeOptions.Asynchronous | PipeOptions.CurrentUserOnly))
{
client.Connect(1000);
if (!client.IsConnected)
Expand Down Expand Up @@ -93,8 +102,8 @@ private async void StartServer()
}
}

private FileStream _singletonLock = null;
private NamedPipeServerStream _server = null;
private CancellationTokenSource _cancellationTokenSource = null;
private readonly FileStream _singletonLock = null;
private readonly NamedPipeServerStream _server = null;
private readonly CancellationTokenSource _cancellationTokenSource = null;
}
}
Loading