Skip to content

Instantly share code, notes, and snippets.

@wackoisgod
Created April 13, 2020 01:10
Show Gist options
  • Save wackoisgod/4047dbb15db347f2332efb8632275966 to your computer and use it in GitHub Desktop.
Save wackoisgod/4047dbb15db347f2332efb8632275966 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Data;
using System.Reflection;
using System.Text.RegularExpressions;
namespace TestEventTracking
{
public class MatchStartedEventArgs : EventArgs
{
}
class Program
{
public static List<KeyValuePair<Delegate, EventArgs>> deferredEvents2 = new List<KeyValuePair<Delegate, EventArgs>>();
public static event EventHandler<MatchStartedEventArgs> MatchStarted;
static void RaiseMatchStarted()
{
if (MatchStarted == null)
{
return;
}
deferredEvents2.Add(new KeyValuePair<Delegate, EventArgs>(MatchStarted, new MatchStartedEventArgs()));
}
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
MatchStarted += Program_MatchStarted;
RaiseMatchStarted();
foreach (KeyValuePair<Delegate, EventArgs> pair in deferredEvents2)
{
pair.Key.Method.Invoke(null, new object[] { null, pair.Value });
}
}
private static void Program_MatchStarted(object sender, MatchStartedEventArgs e)
{
Console.WriteLine("I like candy");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment