private void Send(byte[] cmd, params byte[][] parameters) { if (!Disposed) { var connection = Connect(); if (connection != null) { var pubSubCmd = new RedisCommand(0, cmd, RedisCommandType.SendNotReceive, parameters); connection.SendAsync(pubSubCmd) .ContinueWith(t => pubSubCmd.Dispose()) .Wait(); } } }
protected virtual void SendAsync(byte[] cmd, params byte[][] parameters) { if (!cmd.IsEmpty()) { Action action = () => { var connection = Connect(cmd.CommandRole(), CanBeginReceive(cmd)); if (connection != null) { try { if (connection.Connected) { var command = new RedisCommand(0, cmd, RedisCommandType.SendNotReceive, parameters); connection.SendAsync(command) .ContinueWith(t => { var quitMessage = (command.Command == RedisCommandList.Quit); command.Dispose(); if (quitMessage) { var provider = m_ConnectionProvider; if (provider.IsAlive()) { var scProvider = provider as RedisSingleConnectionProvider; if (scProvider != null) { scProvider.DisposeConnection(); } } } }); } } finally { connection.ReleaseSocket(); } } }; action.InvokeAsync(); } }