Ejemplo n.º 1
0
        /// <summary>
        /// Create new thread with PipeServer.
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task StartAsync(CancellationToken cancellationToken = default)
        {
            return(Task.Run(async() =>
            {
                PipeServer = new PipeServer <string[]>(ApplicationName);
                PipeServer.AddAccessRules(
                    new PipeAccessRule(
                        new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null),
                        PipeAccessRights.ReadWrite,
                        AccessControlType.Allow));

                await PipeServer.StartAsync(cancellationToken).ConfigureAwait(false);

                PipeServer.MessageReceived += (sender, args) =>
                {
                    OnArgumentsReceived(args.Message);
                };
                PipeServer.ExceptionOccurred += (sender, args) =>
                {
                    OnExceptionOccurred(args.Exception);
                };
            }, cancellationToken));
        }