Beispiel #1
0
        public void Send(byte[] buffer, Action callback, Action <Exception> error)
        {
            AsyncSocketSendState state = new AsyncSocketSendState()
            {
                Callback = callback,
                Error    = error,
                Buffer   = buffer
            };

            ThreadPool.QueueUserWorkItem(new WaitCallback(InnerSend), state);
        }
Beispiel #2
0
        private void InnerSend(object state)
        {
            AsyncSocketSendState stateValue = state as AsyncSocketSendState;

            try
            {
                if (stateValue == null)
                {
                    return;
                }

                _socket.Send(stateValue.Buffer);

                stateValue.Callback();
            }
            catch (Exception e)
            {
                stateValue.Error(e);
            }
        }