Example #1
0
        protected override void OnClosed(EventArgs e)
        {
            var res = Closed?.GetInvocationList();

            if (res != null)
            {
                foreach (Delegate d in Closed?.GetInvocationList())
                {
                    Closed -= (EventHandler)d;
                }
            }
            base.OnClosed(e);
        }
 public async Task CloseAsync(string message, Exception exception = null, CancellationToken cancellationToken = default)
 {
     CheckDisposed();
     _logger.LogDebug("开始关闭Hub 连接");
     _sendedPingMessageTimer.Dispose();
     _isStart = false;
     if (Closed.GetInvocationList().Length != 0)
     {
         if (exception != null)
         {
             await Closed.Invoke(new Exception(message, exception));
         }
         else
         {
             await Closed.Invoke(new Exception(message));
         }
     }
 }
Example #3
0
        private void RemoveAllHandledEvents()
        {
            if (Shown != null)
            {
                foreach (var @delegate in Shown.GetInvocationList())
                {
                    var h = (EventHandler)@delegate;
                    Shown -= h;
                }
            }

            if (Closing != null)
            {
                foreach (var @delegate in Closing.GetInvocationList())
                {
                    var h = (CancelEventHandler)@delegate;
                    Closing -= h;
                }
            }

            if (Closed != null)
            {
                foreach (var @delegate in Closed.GetInvocationList())
                {
                    var h = (EventHandler)@delegate;
                    Closed -= h;
                }
            }

            var p = Parent as FrameworkElement;

            if (p != null)
            {
                p.DataContextChanged -= Parent_DataContextChanged;
            }
        }
Example #4
0
 public bool ClosedIsHooked()
 {
     return(Closed != null && Closed.GetInvocationList().Length > 0);
 }