Beispiel #1
0
        void _MidiOutProc(IntPtr handle, int msg, int instance, IntPtr param1, IntPtr param2)
        {
            switch (msg)
            {
            case MOM_OPEN:
                OnOpened(EventArgs.Empty);
                break;

            case MOM_CLOSE:
                OnClosed(EventArgs.Empty);
                break;

            case MOM_DONE:

                if (IntPtr.Zero != param1)
                {
                    var header = Marshal.PtrToStructure <MIDIHDR>(param1);
                    _CheckOutResult(midiOutUnprepareHeader(Handle, param1, Marshal.SizeOf(typeof(MIDIHDR))));
                    Marshal.FreeHGlobal(param1);
                    Interlocked.Exchange(ref _sendQueuePosition, 0);
                    Interlocked.Exchange(ref _sendQueue, null);
                }

                if (null == _sendQueue)
                {
                    SendComplete?.Invoke(this, EventArgs.Empty);
                }
                else
                {
                    _SendBlock();
                }
                break;
            }
        }
Beispiel #2
0
        void _MidiOutProc(IntPtr handle, int msg, int instance, int param1, int param2)
        {
            switch (msg)
            {
            case MOM_OPEN:
                Opened?.Invoke(this, EventArgs.Empty);
                break;

            case MOM_CLOSE:
                Closed?.Invoke(this, EventArgs.Empty);
                break;

            case MOM_DONE:

                if (IntPtr.Zero != _sendHeader.lpData)
                {
                    _CheckOutResult(midiOutUnprepareHeader(_handle, ref _sendHeader, Marshal.SizeOf(typeof(MIDIHDR))));
                    Interlocked.Exchange(ref _sendHeader.lpData, IntPtr.Zero);
                    Interlocked.Exchange(ref _sendQueuePosition, 0);
                    Interlocked.Exchange(ref _sendQueue, null);
                }

                if (null == _sendQueue)
                {
                    SendComplete?.Invoke(this, EventArgs.Empty);
                }
                else
                {
                    _SendBlock();
                }
                break;
            }
        }
Beispiel #3
0
        private void SocketArg_Completed(object sender, SocketAsyncEventArgs e)
        {
            lock (locker)
            {
                switch (e.LastOperation)
                {
                case SocketAsyncOperation.Receive:
                    //数据接收成功且不为0,则将收到数据写入缓存池,并触发接收完成事件
                    if (e.SocketError == SocketError.Success && e.BytesTransferred > 0)
                    {
                        bufferPool.EnCache(socketArg.Buffer, socketArg.BytesTransferred);

                        ///收到报文记录
                        byte[] logByte = new byte[socketArg.BytesTransferred];
                        Array.Copy(socketArg.Buffer, logByte, logByte.Length);
                        log.ByteSteamLog(ActionType.RECEIVE, logByte);

                        ReadComplete?.Invoke(this);
                    }
                    else
                    {
                        Clear();
                        if (_m_ConnectStatePool != null)
                        {
                            _m_ConnectStatePool.Return(this);
                        }
                    }
                    break;

                case SocketAsyncOperation.Send:
                    //数据发送成功且不为0,触发发送完成事件
                    if (e.SocketError == SocketError.Success && e.BytesTransferred > 0)
                    {
                        SendComplete?.Invoke(this);
                    }
                    else
                    {
                        Clear();
                        if (_m_ConnectStatePool != null)
                        {
                            _m_ConnectStatePool.Return(this);
                        }
                    }
                    break;

                default:
                    Clear();
                    if (_m_ConnectStatePool != null)
                    {
                        _m_ConnectStatePool.Return(this);
                    }
                    break;
                }
            }
        }
Beispiel #4
0
        private void SendCallback()
        {
            Application.Invoke(() =>
            {
                toolProgress.Visible    = false;
                listDocuments.Sensitive = true;
                listDocuments.RefreshBounds(false);
                var send   = items.Select("Work.IsComplete", CompareType.Equal, true);
                var restor = items.Select("Work", CompareType.Equal, null);
                var sended = send.Union(restor).ToList();
                MessageDialog.ShowMessage(this, string.Format("Sended {0} of {1} documents", sended.Count, items.Count));

                if (sended.Count == items.Count)
                {
                    Hide();
                    DResult = Command.Ok;
                }
                SendComplete?.Invoke(this, EventArgs.Empty);
            });
        }
 /// <summary>
 ///异步发送数据反馈
 /// </summary>
 /// <param name="result"></param>
 private void SendCallback(IAsyncResult result)
 {
     try
     {
         int sendCount = currentSocket.EndReceive(result);
         if (sendCount > 0)
         {
             SendComplete?.Invoke(this, sendCount);
         }
         else
         {
             Disconnect();
             Dispose();
         }
     }
     catch (SocketException ex)
     {
         string error = string.Format("Send Callback data Error:{0}, ID:{1}, IPAdderss:{2}", ex.Message, id, currentSocket.RemoteEndPoint);
         log.ErrorLog(error);
         Disconnect();
         Dispose();
     }
 }
Beispiel #6
0
 protected virtual void OnSendComplete(EventArgs args)
 {
     SendComplete?.Invoke(this, args);
 }
Beispiel #7
0
 private void ConnectState_SendComplete(SaeaConnectState obj)
 {
     SendComplete?.Invoke(obj);
 }
Beispiel #8
0
 private void SenderSendComplete(object sender, EventArgs e)
 {
     CheckState(DocumentEditorState.None);
     SendComplete?.Invoke(this, e);
 }
Beispiel #9
0
 private void APMServer_SendComplete(APMConnectState arg1, int arg2)
 {
     SendComplete?.Invoke(arg1);
 }