private void SafeInvokeScreenshotReceived(ScreenshotReceivedEventArgs eventArgs) { if (ScreenshotReceived == null) { return; //No Listeners } ScreenshotReceivedEvent listener = null; Delegate[] dels = ScreenshotReceived.GetInvocationList(); foreach (Delegate del in dels) { try { listener = (ScreenshotReceivedEvent)del; listener.Invoke(eventArgs); } catch (Exception) { //Could not reach the destination, so remove it //from the list ScreenshotReceived -= listener; } } }
private void SafeInvokeScreenshotReceived(ScreenshotReceivedEventArgs eventArgs) { if (ScreenshotReceived == null) return; //No Listeners ScreenshotReceivedEvent listener = null; Delegate[] dels = ScreenshotReceived.GetInvocationList(); foreach (Delegate del in dels) { try { listener = (ScreenshotReceivedEvent)del; listener.Invoke(eventArgs); } catch (Exception) { //Could not reach the destination, so remove it //from the list ScreenshotReceived -= listener; } } }