本文整理汇总了C#中System.IO.Pipes.NamedPipeServerStream.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# NamedPipeServerStream.GetHashCode方法的具体用法?C# NamedPipeServerStream.GetHashCode怎么用?C# NamedPipeServerStream.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.Pipes.NamedPipeServerStream
的用法示例。
在下文中一共展示了NamedPipeServerStream.GetHashCode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
// Create a name pipe
NamedPipeServerStream pipeStream = null;
try
{
pipeStream = new NamedPipeServerStream(LogManager.ConnectionName, PipeDirection.InOut, 1, PipeTransmissionMode.Message);
Console.WriteLine("Log Monitor started: " + pipeStream.GetHashCode());
// Wait for a connection
pipeStream.WaitForConnection();
Console.WriteLine("Connection established");
using (StreamReader sr = new StreamReader(pipeStream))
{
pipeStream = null;
string temp;
// We read a line from the pipe and print it together with the current time
while ((temp = sr.ReadLine()) != null)
{
Console.WriteLine(temp);
}
}
}
finally
{
if (pipeStream != null)
{
pipeStream.Dispose();
}
}
Console.WriteLine("Connection lost");
Console.WriteLine("Press <ENTER> to quit");
Console.ReadLine();
}
示例2: createNamePipeServer
public static NamedPipeServerStream createNamePipeServer(string pipeName, Action<string> dataReceived, Action onPipeTerminated)
{
var namedPipeServerStream = new NamedPipeServerStream(pipeName);
"[NamePipeServer][{0}] Pipe created {1}".format(pipeName, namedPipeServerStream.GetHashCode()).info();
O2Thread.mtaThread(
() =>
{
namedPipeServerStream.WaitForConnection();
"[NamePipeServer][{0}] Pipe connection established".format(pipeName).info();
using (var streamReader = new StreamReader(namedPipeServerStream))
{
string line;
while ((line = streamReader.ReadLine()) != null)
{
//"received text:{0}".format(line).debug();
dataReceived(line);
}
"[NamePipeServer][{0}] Connection lost or pipe terminated".format(pipeName).info();
if (onPipeTerminated != null)
onPipeTerminated();
}
});
return namedPipeServerStream;
}
示例3: ThreadStartServer
public void ThreadStartServer(object o)
{
// Create a name pipe
using (NamedPipeServerStream pipeStream = new NamedPipeServerStream("CommPipe"))
{
Console.WriteLine("[Server] Pipe created {0}", pipeStream.GetHashCode());
// Wait for a connection
pipeStream.WaitForConnection();
MainWindow.obj.Name += "\n[Server] Pipe connection established";
using (StreamReader sr = new StreamReader(pipeStream))
{
string temp;
// We read a line from the pipe and print it together with the current time
var ViewModel = o as IImageListViewModel;
while ((temp = sr.ReadLine()) != "End Connection")
{
if (temp != null)
MainWindow.obj.Name += "\n" + temp;
}
MainWindow.obj.Name += "\n[Server] Connection terminated";
}
}
}