Hello I am having a strange problem in .net 4.0. I am calling the following code from my main form thread and I am getting an "object reference not set to an instance" exception on variable MainForm.NumberOFWindows(although it is initialized) and I can not figure out why. The really strange thing for me is that the exception is not being catched by the try catch exception clause either. Can someone please shred some light to my problem? Why does the exception occurs and why it is not being catched by the try catch clause?
try
{
MyThread = new Thread(delegate()
{
Notify.UserInput(this,ref MainForm.NumberOFWindows);
});
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}