本文整理汇总了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);
}
}
}
示例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;
}
示例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);
}
}
}
示例4: Server
private void Server()
{
using (var s = new NamedPipeServerStream("pipedream"))
{
s.WaitForConnection();
byte b = 0x1;
while (true)
{
s.WriteByte(b++);
Thread.Sleep(10);
}
}
}