Hello,

I just discovered a problem that has caused much grief. Basically,
inside of a form method (for example, OnLoad()) I call a delegate that
has a parameter of the current form. The delegate gets executed and
the forms properties are accessible from the delegate routine.
However, if I set a breakpoint inside of the delegate code, the IDE
hangs and after teh breakpoint is reached, the thread dies. If I
don't pass the form as a parameter to the delegate, everything works
correctly! Here is example code. I hope someone can fill me in as to
what is going on:

public partial class TestForm : Form
{
delegate void FormArgDelegate(TestForm form);

public TestForm()
{
InitializeComponent();
}

private void SimpleRoutine(TestForm form)
{
Console.WriteLine("I am a simple routine. I ran.");
Thread.Sleep(2000);
Console.WriteLine("I waited and now I'm done");
}

void RunRoutine()
{
FormArgDelegate del = new FormArgDelegate(SimpleRoutine);

del(this);
//del(null);
}

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);

Thread testThread = new Thread(new ThreadStart(RunRoutine));
testThread.Start();
}
}

Not much going on here, but set a breakpoint in SimpleRoutine(...) and
see what happens.

Any ideas?

Best regards,
-Sean