private static void AssureSendOld(ClientManager clientManager, byte[] buffer, int count, SendContext context) { TimeSpan tempTaken; try { Send(clientManager, buffer, count); SendContext opContext = null; do { opContext = null; lock (clientManager) { if (clientManager.PendingSendOperationQueue.Count > 0) { object operation = clientManager.PendingSendOperationQueue.remove(); opContext = (SendContext)operation; clientManager.ResetAsyncSendTime(); if (SocketServer.IsServerCounterEnabled) clientManager.ConnectionManager.PerfStatsColl.DecrementResponsesQueueCountStats(); if (SocketServer.IsServerCounterEnabled) clientManager.ConnectionManager.PerfStatsColl.DecrementResponsesQueueSizeStats(opContext.expectedSize); } } if (opContext != null) { Send(opContext.clientManager, opContext.buffer, opContext.expectedSize); } lock (clientManager) { if (clientManager.PendingSendOperationQueue.Count == 0) { clientManager.DeMarkOperationInProcess(); return; } } } while (clientManager.PendingSendOperationQueue.Count > 0); } catch (Exception e) { if (SocketServer.Logger != null && SocketServer.Logger.IsErrorLogsEnabled) SocketServer.Logger.NCacheLog.Error("ConnectionManager.AssureSend", e.ToString()); DisposeClient(clientManager); } }
private static void AssureSend(ClientManager clientManager, byte[] buffer, int count, SendContext context) { try { Send(clientManager, buffer, count); lock (clientManager) { if (clientManager.PendingSendOperationQueue.Count == 0) { clientManager.DeMarkOperationInProcess(); return; } } #if !NET20 try { Task t = null; //as there are times in the queue; let's start sending pending responses in separate thread. TaskFactory factory = new TaskFactory(TaskCreationOptions.LongRunning, TaskContinuationOptions.LongRunning); t = factory.StartNew(() => ProccessResponseQueue(clientManager), TaskCreationOptions.LongRunning); } catch (AggregateException aggEx) { } #else ThreadPool.QueueUserWorkItem(new WaitCallback(ProccessResponseQueue), clientManager); #endif } catch (Exception e) { if (SocketServer.Logger != null && SocketServer.Logger.IsErrorLogsEnabled) SocketServer.Logger.NCacheLog.Error("ConnectionManager.AssureSend", e.ToString()); DisposeClient(clientManager); } }