当前位置: 首页>>代码示例>>C#>>正文


C# NamedPipeServerStream.WriteByte方法代码示例

本文整理汇总了C#中System.IO.Pipes.NamedPipeServerStream.WriteByte方法的典型用法代码示例。如果您正苦于以下问题:C# NamedPipeServerStream.WriteByte方法的具体用法?C# NamedPipeServerStream.WriteByte怎么用?C# NamedPipeServerStream.WriteByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.Pipes.NamedPipeServerStream的用法示例。


在下文中一共展示了NamedPipeServerStream.WriteByte方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

        public void Start()
        {
            Console.WriteLine("Магазин создан. Pipe: {0}.", PipeName);

            while (true)
            {
                pipeServer = CreatePipeServer();
                pipeServer.WaitForConnection();
                try
                {
                    int userId = pipeServer.ReadByte();
                    var command = (Request)pipeServer.ReadByte();
                    if (userId == 0)
                    {
                        id += 1;
                        pipeServer.WriteByte((byte)id);
                        userId = id;
                    }
                    else
                    {
                        pipeServer.WriteByte((byte)userId);
                    }

                    switch (command)
                    {
                        case Request.GoSection:
                            HandleGoSection(userId);
                            break;
                        case Request.LeftSection:
                            HandleLeftSection(userId);
                            break;
                        case Request.IsVendorVacant:
                            HandleIsVendorVacant(userId);
                            break;
                        case Request.NewVendor:
                            HandleNewVendor(userId);
                            break;
                        case Request.NewBuyer:
                            HandleNewBuyer(userId);
                            break;
                        default:
                            Console.WriteLine("Неизвестная команда");
                            break;
                    }
                    pipeServer.WaitForPipeDrain();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }
开发者ID:REVcon,项目名称:PP,代码行数:52,代码来源:ShopServer.cs

示例2: PingPong_OtherProcess

        private static int PingPong_OtherProcess(string inName, string outName)
        {
            // Create pipes with the supplied names
            using (var inbound = new NamedPipeClientStream(".", inName, PipeDirection.In))
            using (var outbound = new NamedPipeServerStream(outName, PipeDirection.Out))
            {
                // Wait for the connections to be established
                Task.WaitAll(inbound.ConnectAsync(), outbound.WaitForConnectionAsync());

                // Repeatedly read then write bytes from and to the other process
                for (int i = 0; i < 10; i++)
                {
                    int b = inbound.ReadByte();
                    outbound.WriteByte((byte)b);
                }
            }
            return SuccessExitCode;
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:18,代码来源:NamedPipesTests.cs

示例3: PingPong

        public void PingPong()
        {
            // Create names for two pipes
            string outName = Guid.NewGuid().ToString("N");
            string inName = Guid.NewGuid().ToString("N");

            // Create the two named pipes, one for each direction, then create
            // another process with which to communicate
            using (var outbound = new NamedPipeServerStream(outName, PipeDirection.Out))
            using (var inbound = new NamedPipeClientStream(".", inName, PipeDirection.In))
            using (var remote = RemoteInvoke(PingPong_OtherProcess, outName, inName))
            {
                // Wait for both pipes to be connected
                Task.WaitAll(outbound.WaitForConnectionAsync(), inbound.ConnectAsync());

                // Repeatedly write then read a byte to and from the other process
                for (byte i = 0; i < 10; i++)
                {
                    outbound.WriteByte(i);
                    int received = inbound.ReadByte();
                    Assert.Equal(i, received);
                }
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:24,代码来源:NamedPipesTests.cs

示例4: Server

 private void Server()
 {
     using (var s = new NamedPipeServerStream("pipedream"))
     {
         s.WaitForConnection();
         byte b = 0x1;
         while (true)
         {
             s.WriteByte(b++);
             Thread.Sleep(10);
         }
     }
 }
开发者ID:simonlaroche,项目名称:DumpingGrounds,代码行数:13,代码来源:PipeStreams.cs


注:本文中的System.IO.Pipes.NamedPipeServerStream.WriteByte方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。