static void Main()
{
ExecuteCommand();
Debug.Assert(CommandExecuted == null);
ExecuteCommandLeaks();
//This assert will fail
Debug.Assert(CommandExecuted == null);
}
static void ExecuteCommandLeaks()
{
CommandExecuted += new EventHandler<EventArgs>((o, e) => Console.WriteLine("Event called"));
CommandExecuted.Invoke(new object(), new EventArgs());
}
static void ExecuteCommand()
{
var commandCapture = new EventHandler<EventArgs>((o, e) => Console.WriteLine("Event called"));
CommandExecuted += commandCapture;
CommandExecuted.Invoke(new object(), new EventArgs());
CommandExecuted -= commandCapture;
}
static EventHandler<EventArgs> CommandExecuted;
Of course, what a great site and informative posts, I will add backlink - bookmark this site? Regards, Reader.
ReplyDeleterH3uYcBX
which is the proper one?
ReplyDeleteA SUPPORTED BY THE DEVELOPER TOOLS? It was interesting. You seem very knowledgeable in ypour field.
ReplyDeleteYour blog keeps getting better and better! Your older articles are not as good as newer ones you have a lot more creativity and originality now keep it up!
ReplyDeleteGreat article! Well stated!!
ReplyDeleteLet well alone
ReplyDelete