/// <summary>
        /// The non-obsolete constructor used internally for creating new instances of XDListener.
        /// </summary>
        /// <param name="nonObsolete"></param>
        internal XDListener(bool nonObsolete)
        {
            // create a top-level native window
            CreateParams p = new CreateParams();
            p.Width = 0;
            p.Height = 0;
            p.X = 0;
            p.Y = 0;
            p.Caption = string.Concat("TheCodeKing.Net.XDServices.",Guid.NewGuid().ToString());
            p.Parent = IntPtr.Zero;
            base.CreateHandle(p);

            this.networkRelay = new NetworkRelayListener(XDBroadcast.CreateBroadcast(XDTransportMode.WindowsMessaging), 
                                                            XDListener.CreateListener(XDTransportMode.MailSlot));
        }
        /// <summary>
        /// Dispose implementation which ensures the native window is destroyed, and
        /// managed resources detached.
        /// </summary>
        private void Dispose(bool disposeManaged)
        {
            if (!disposed)
            {
                disposed = true;
                if (disposeManaged)
                {
                    if (networkRelay != null)
                    {
                        networkRelay.Dispose();
                        networkRelay = null;
                    }

                    if (MessageReceived != null)
                    {
                        // remove all handlers
                        Delegate[] del = MessageReceived.GetInvocationList();
                        foreach (XDMessageHandler msg in del)
                        {
                            MessageReceived -= msg;
                        }
                    }
                    if (this.Handle != IntPtr.Zero)
                    {
                        this.DestroyHandle();
                        this.Dispose();
                    }
                }
            }
        }