예제 #1
0
        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));
        }
예제 #2
0
        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);
                }
            }
        }
예제 #3
0
 public ModalForm(MessagePipe pipe)
 {
     _pipe = pipe ?? throw new ArgumentNullException(nameof(pipe));
 }