protected override void WndProc(ref Message msg) { base.WndProc(ref msg); if (msg.Msg != Native.WM_COPYDATA) { return; } using (var dataGram = WinMsgDataGram.FromPointer(msg.LParam, serializer)) { if (MessageReceived != null && dataGram != null && dataGram.IsValid) { MessageReceived.Invoke(this, new XDMessageEventArgs(dataGram)); } } }
/// <summary> /// The native window message filter used to catch our custom WM_COPYDATA /// messages containing cross AppDomain messages. All other messages are ignored. /// </summary> /// <param name = "msg">A representation of the native Windows Message.</param> protected override void WndProc(ref Message msg) { base.WndProc(ref msg); if (msg.Msg != Native.WM_COPYDATA) { return; } // we can free any unmanaged resources immediately in the dispose, managed channel and message // data will still be retained in the object passed to the event using (var dataGram = WinMsgDataGram.FromPointer(msg.LParam, serializer)) { if (MessageReceived != null && dataGram.IsValid) { MessageReceived.Invoke(this, new XDMessageEventArgs(dataGram)); } } }