예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="state"></param>
        public void Post(int id, object state)
        {
            SendOrPostCallback d        = GetSendOrPostCallback();
            PostStateObject    stateObj = new PostStateObject(id, state);

            this.SyncContext.Post(d, stateObj);
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="state"></param>
        private void SendOrPostCallbackTarget(object state)
        {
            PostStateObject stateObj = state as PostStateObject;

            switch (stateObj.ID)
            {
            case ID_RECEIVEDBYTES:
                byte[] bs = stateObj.State as byte[];
                this.AddReceived(
                    GetRemoteString(),
                    GetLocalString(),
                    bs);

                if (this.ReplyCollection.Enabled)
                {
                    byte[] bsr = this.ReplyCollection.GetSendBytes(bs);
                    if (bsr != null)
                    {
                        this.SocketClient.Send(bsr);
                        this.AddSend(
                            GetLocalString(),
                            GetRemoteString(),
                            bsr);
                    }
                }

                Transmit(this.SocketClient, bs);
                break;

            case ID_SOCKETCLOSED:
                this.OnSocketClosed();
                break;

            case ID_SERIALPORT_RECEIVED:
                byte[] bs2 = (byte[])stateObj.State;
                this.AddReceived(
                    GetSerialPortName(),
                    this.GetMe(),
                    bs2);
                Transmit(this.SerialPortManager, bs2);
                break;
            }
        }