public Task StartAsync(CancellationToken cancellationToken) { return(Task.Run(async() => { cancellationToken.ThrowIfCancellationRequested(); EnsureJob(); _pipeName = $"advantage_{Guid.NewGuid()}"; _process = StartProcess(); if (_process == null) { return; } _messagePipe = await OpenPipeAsync(cancellationToken); _messagePipeSubject.OnNext(_messagePipe); }, cancellationToken)); }
private async Task <MessagePipe> OpenPipeAsync(CancellationToken cancellationToken) { while (true) { cancellationToken.ThrowIfCancellationRequested(); try { var messagePipe = new MessagePipe(_pipeName); await messagePipe.Connect(cancellationToken).ConfigureAwait(false); await messagePipe.PingAsync(cancellationToken); return(messagePipe); } catch (Exception ex) { Debug.WriteLine(ex); await Task.Delay(1000, cancellationToken).ConfigureAwait(false); } } }
public ModalForm(MessagePipe pipe) { _pipe = pipe ?? throw new ArgumentNullException(nameof(pipe)); }