public async Task StartAsync()
{
if (_client?.State == PipeState.Connected)
return;
This commit is contained in:
@@ -5,7 +5,7 @@ using System.Diagnostics;
|
|||||||
namespace PipeClient;
|
namespace PipeClient;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Owns the server process and the pipe client connected to it.
|
/// Manages a pipe client and any server process it starts.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class ServerConnection(string pipeName, Action<string> log) : IDisposable
|
internal sealed class ServerConnection(string pipeName, Action<string> log) : IDisposable
|
||||||
{
|
{
|
||||||
@@ -19,6 +19,9 @@ internal sealed class ServerConnection(string pipeName, Action<string> log) : ID
|
|||||||
|
|
||||||
public async Task StartAsync()
|
public async Task StartAsync()
|
||||||
{
|
{
|
||||||
|
if (_client?.State == PipeState.Connected)
|
||||||
|
return;
|
||||||
|
|
||||||
var process = StartServerProcess(PipeName);
|
var process = StartServerProcess(PipeName);
|
||||||
process.EnableRaisingEvents = true;
|
process.EnableRaisingEvents = true;
|
||||||
process.Exited += (_, _) =>
|
process.Exited += (_, _) =>
|
||||||
@@ -34,7 +37,7 @@ internal sealed class ServerConnection(string pipeName, Action<string> log) : ID
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Kills the (unresponsive) server process and starts a new one.
|
/// Kills the owned server process, if any, and starts a new one.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task KillAndRestartAsync()
|
public async Task KillAndRestartAsync()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user