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;
6 comments:
Of course, what a great site and informative posts, I will add backlink - bookmark this site? Regards, Reader.
rH3uYcBX
which is the proper one?
A SUPPORTED BY THE DEVELOPER TOOLS? It was interesting. You seem very knowledgeable in ypour field.
Your 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!
Great article! Well stated!!
Let well alone
Post a Comment