Exemplo n.º 1
0
 private static Func <IServiceProvider, NamedPipeChannel> CreateConfiguredNamedPipeChannel()
 {
     return(serviceProvider =>
     {
         var options = new NamedPipeChannelOptions();
         options.ConnectionTimeout = (int)TimeSpan.FromSeconds(3).TotalMilliseconds;
         var channel = new NamedPipeChannel(".", Globals.NamedPipeChannel, options);
         return channel;
     });
 }
Exemplo n.º 2
0
        public static INamedPipeClientStream CreateClient(string serverName, string pipeName,
                                                          NamedPipeChannelOptions options)
        {
            var pipeOptions = PipeOptions.Asynchronous;

#if NETCOREAPP || NETSTANDARD2_1
            if (options.CurrentUserOnly)
            {
                pipeOptions |= PipeOptions.CurrentUserOnly;
            }
#endif

            var stream = new NamedPipeClientStreamFacade(new NamedPipeClientStream(serverName, pipeName, PipeDirection.InOut,
                                                                                   pipeOptions, options.ImpersonationLevel, HandleInheritability.None));
            return(stream);
        }