mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
enhance: bring window into view after receive IPC message
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
e2da44c8fd
commit
c4c04b8b01
4 changed files with 53 additions and 22 deletions
|
@ -46,14 +46,19 @@ namespace SourceGit.Models
|
|||
using (var client = new NamedPipeClientStream(".", "SourceGitIPCChannel", PipeDirection.Out))
|
||||
{
|
||||
client.Connect(1000);
|
||||
if (client.IsConnected)
|
||||
if (!client.IsConnected)
|
||||
return;
|
||||
|
||||
using (var writer = new StreamWriter(client))
|
||||
{
|
||||
using (var writer = new StreamWriter(client))
|
||||
{
|
||||
writer.WriteLine(cmd);
|
||||
writer.Flush();
|
||||
}
|
||||
writer.WriteLine(cmd);
|
||||
writer.Flush();
|
||||
}
|
||||
|
||||
if (OperatingSystem.IsWindows())
|
||||
client.WaitForPipeDrain();
|
||||
else
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
@ -78,13 +83,18 @@ namespace SourceGit.Models
|
|||
{
|
||||
await _server.WaitForConnectionAsync(_cancellationTokenSource.Token);
|
||||
|
||||
var line = (await reader.ReadLineAsync(_cancellationTokenSource.Token))?.Trim();
|
||||
MessageReceived?.Invoke(line);
|
||||
if (!_cancellationTokenSource.IsCancellationRequested)
|
||||
{
|
||||
var line = await reader.ReadToEndAsync(_cancellationTokenSource.Token);
|
||||
MessageReceived?.Invoke(line?.Trim());
|
||||
}
|
||||
|
||||
_server.Disconnect();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// IGNORE
|
||||
if (!_cancellationTokenSource.IsCancellationRequested && _server.IsConnected)
|
||||
_server.Disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue