public partial class Form1 : Form
{
public class abc
{
public static decimal Divide(int a,int b)
{
return a / b;
}
}
public Form1()
{
InitializeComponent();
numericUpDown1.ValueChanged += NumericUpDown1_ValueChanged;
numericUpDown1.Controls[1].Leave += Form1_Leave;
}
private void Form1_Leave(object sender, EventArgs e)
{
//abc.Divide(15, 0);
}
private void NumericUpDown1_ValueChanged(object sender, EventArgs e)
{
abc.Divide(15, 0);
}
}
And Program.cs is haveing catch block as follow
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.ThreadException += Application_ThreadException;
try
{
Application.Run(new Form1());
}
catch
{
MessageBox.Show("Exception Hadled");
}
}
private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
MessageBox.Show("Exception Hadnled");
}
}
In Above sample, no message box is triggered. But if I use leave event catch executes. Why ValueChanged event is not Prapogating exception to outer world?