Пример #1
0
        protected void OnMessageReceived(byte[] message)
        {
            if (MessageReceived == null)
            {
                return;
            }

            DeviceMessageHandler eventHandler = MessageReceived;

            Delegate[] delegates = eventHandler.GetInvocationList();
            foreach (DeviceMessageHandler handler in delegates)
            {
                DispatcherObject dispatcherObject = handler.Target as DispatcherObject;
                if (dispatcherObject != null && !dispatcherObject.CheckAccess())
                {
                    dispatcherObject.Dispatcher.Invoke(DispatcherPriority.DataBind, handler, this, message);
                }
                else
                {
                    handler(this, message);
                }
            }
        }