本文整理汇总了C#中System.Threading.ManualResetEvent.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# ManualResetEvent.GetHashCode方法的具体用法?C# ManualResetEvent.GetHashCode怎么用?C# ManualResetEvent.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Threading.ManualResetEvent
的用法示例。
在下文中一共展示了ManualResetEvent.GetHashCode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DualModeConnect_AcceptAsync_Helper
private void DualModeConnect_AcceptAsync_Helper(IPAddress listenOn, IPAddress connectTo)
{
using (Socket serverSocket = new Socket(SocketType.Stream, ProtocolType.Tcp))
{
int port = serverSocket.BindToAnonymousPort(listenOn);
serverSocket.Listen(1);
SocketAsyncEventArgs args = new SocketAsyncEventArgs();
args.Completed += AsyncCompleted;
ManualResetEvent waitHandle = new ManualResetEvent(false);
args.UserToken = waitHandle;
_log.WriteLine(args.GetHashCode() + " SocketAsyncEventArgs with manual event " + waitHandle.GetHashCode());
serverSocket.AcceptAsync(args);
SocketClient client = new SocketClient(serverSocket, connectTo, port);
Assert.True(waitHandle.WaitOne(Configuration.PassingTestTimeout), "Timed out while waiting for connection");
if (args.SocketError != SocketError.Success)
{
throw new SocketException((int)args.SocketError);
}
Socket clientSocket = args.AcceptSocket;
Assert.NotNull(clientSocket);
Assert.True(clientSocket.Connected);
Assert.True(clientSocket.DualMode);
Assert.Equal(AddressFamily.InterNetworkV6, clientSocket.AddressFamily);
Assert.Equal(connectTo.MapToIPv6(), ((IPEndPoint)clientSocket.LocalEndPoint).Address);
}
}
示例2: DualModeConnect_AcceptAsync_Helper
private void DualModeConnect_AcceptAsync_Helper(IPAddress listenOn, IPAddress connectTo)
{
using (Socket serverSocket = new Socket(SocketType.Stream, ProtocolType.Tcp))
{
int port = serverSocket.BindToAnonymousPort(listenOn);
serverSocket.Listen(1);
SocketAsyncEventArgs args = new SocketAsyncEventArgs();
args.Completed += AsyncCompleted;
ManualResetEvent waitHandle = new ManualResetEvent(false);
args.UserToken = waitHandle;
args.SocketError = SocketError.SocketError;
_log.WriteLine(args.GetHashCode() + " SocketAsyncEventArgs with manual event " + waitHandle.GetHashCode());
if (!serverSocket.AcceptAsync(args))
{
throw new SocketException((int)args.SocketError);
}
SocketClient client = new SocketClient(_log, serverSocket, connectTo, port);
var waitHandles = new WaitHandle[2];
waitHandles[0] = waitHandle;
waitHandles[1] = client.WaitHandle;
int completedHandle = WaitHandle.WaitAny(waitHandles, Configuration.PassingTestTimeout);
if (completedHandle == WaitHandle.WaitTimeout)
{
throw new TimeoutException("Timed out while waiting for either of client and server connections...");
}
if (completedHandle == 1) // Client finished
{
if (client.Error != SocketError.Success)
{
// Client SocketException
throw new SocketException((int)client.Error);
}
if (!waitHandle.WaitOne(5000)) // Now wait for the server.
{
throw new TimeoutException("Timed out while waiting for the server accept...");
}
}
_log.WriteLine(args.SocketError.ToString());
if (args.SocketError != SocketError.Success)
{
throw new SocketException((int)args.SocketError);
}
Socket clientSocket = args.AcceptSocket;
Assert.NotNull(clientSocket);
Assert.True(clientSocket.Connected);
AssertDualModeEnabled(clientSocket, listenOn);
Assert.Equal(AddressFamily.InterNetworkV6, clientSocket.AddressFamily);
if (connectTo == IPAddress.Loopback)
{
Assert.Contains(((IPEndPoint)clientSocket.LocalEndPoint).Address, ValidIPv6Loopbacks);
}
else
{
Assert.Equal(connectTo.MapToIPv6(), ((IPEndPoint)clientSocket.LocalEndPoint).Address);
}
clientSocket.Dispose();
}
}
示例3: WaitForNoneReconnection
private static void WaitForNoneReconnection(
IClientSessionChannel channel, IMessage message, ManualResetEvent latch)
{
if (null != message && null != latch)
{
string action = GetAdviceAction(message.Advice, Message.ReconnectNoneValue);
if (Message.ReconnectNoneValue.Equals(action, StringComparison.OrdinalIgnoreCase))
{
latch.Set();// Signal()
// DEBUG
logger.InfoFormat("None reconnection message was found, signal Latch#{0}", latch.GetHashCode());
}
}
}