public void ProcessMessage(CommunicationMessageFull messageInfo)
 {
     //sw.WriteLine("get msg = " + messageInfo.MessageInfo.Message);
     if (_windowHandle != messageInfo.MessageInfo.HWnd.ToInt32())
         Console.WriteLine(messageInfo.MessageInfo.Message);
         //sw.WriteLine("wnd = " + _windowHandle);
 }
 public void OnRecieved(byte[] data, int count = 0)
 {
     if (count == 0)
         count = data != null ? data.Length : 0;
     var recieved = Recieved;
     if (recieved != null)
     {
         IntPtr intPtr = Marshal.AllocHGlobal(_descSize);
         Marshal.Copy(data, 0, intPtr, _descSize);
         CommunicationMessageDesc msgDesc = (CommunicationMessageDesc)Marshal.PtrToStructure(intPtr, typeof(CommunicationMessageDesc));
         Marshal.FreeHGlobal(intPtr);
         var additionalData = new byte[count - _descSize];
         Array.Copy(data, _descSize, additionalData, 0, additionalData.Length);
         CommunicationMessageFull msg = new CommunicationMessageFull
         {
             MessageInfo = msgDesc,
             AdditionalInfo = additionalData
         };
         recieved(msg);
     }
 }