本文整理汇总了C#中ISocket.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# ISocket.Dispose方法的具体用法?C# ISocket.Dispose怎么用?C# ISocket.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISocket
的用法示例。
在下文中一共展示了ISocket.Dispose方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnClose
public void OnClose(ISocket socket)
{
Debug.WriteLine("Socket OnClose.");
socket.Dispose();
// release (indirect) reference to socket
transactionDelegateSubscription.Dispose();
transactionDelegateSubscription = null;
// XXX return self to freelist
}
示例2: OnConnection
public ISocketDelegate OnConnection(IServer server, ISocket socket)
{
NumOnConnectionEvents++;
if (OnConnectionAction != null)
{
return OnConnectionAction(server, socket);
}
else
{
socket.Dispose();
return null;
}
}
示例3: Reclaim
private void Reclaim(ISocket socket) {
if(_disposed) {
socket.Dispose();
return;
}
lock(_syncroot) {
if(!_busySockets.Remove(socket)) {
return;
}
if(socket.IsDisposed) {
// drop disposed sockets
socket.Dispose();
return;
}
// Try to hand the socket to the next client waiting in line
if(_waitingQueue.ProvideSocket(socket)) {
return;
}
if(_availableSockets.Count + _busySockets.Count >= MaxConnections) {
// drop socket if we've already hit the max
socket.Dispose();
return;
}
// Add reclaimed socket to end of available list
_availableSockets.Add(new Available(socket));
}
}
示例4: Reclaim
private void Reclaim(ISocket socket) {
if(_disposed) {
socket.Dispose();
return;
}
lock(_availableSockets) {
if(!_busySockets.Remove(socket)) {
return;
}
if(!socket.Connected || _availableSockets.Count + _busySockets.Count >= MaxConnections) {
// drop socket
socket.Dispose();
return;
}
_availableSockets.Enqueue(new Available(socket));
}
}