I was added handler to Application:
Application.ThreadException += (sender, a) => UnhandledExceptionsHelper.ApplicationOnThreadException(a, null);
After this i want to add another handler
Application.ThreadException += (sender, a) => UnhandledExceptionsHelper.ApplicationOnThreadException(a, param);
How can i remove previous handler?
When i delete handlers from Control i just use:
public void RemoveOnThreadException(SimpleButton b)
{
FieldInfo f1 = typeof(Control).GetField("EventClick",
BindingFlags.Static | BindingFlags.NonPublic);
object obj = f1.GetValue(b);
PropertyInfo pi = b.GetType().GetProperty("Events",
BindingFlags.NonPublic | BindingFlags.Instance);
EventHandlerList list = (EventHandlerList)pi.GetValue(b, null);
list.RemoveHandler(obj, list[obj]);
}
How can i do the same with Application and AppDomain?
@Andrey there is my tries with Button.Click:
public TestForm()
{
InitializeComponent();
simpleButton1.Click += (sender, a) => simpleButton1_Click(sender,a);
simpleButton1.Click -= simpleButton1_Click;
simpleButton1.Click += (sender, a) => simpleButton1_Click(sender, a);
}
private void simpleButton1_Click(object sender, EventArgs e)
{
MessageBox.Show("Hi");
}
And when i click button i got two Messages.