The following method is launched from the constructor of UserControl. A cross thread exception is thrown, but I can't tell why:
public override void Populate()
{
base.Populate ();
LoadEditableList(IEditableList);
ThreadStart fix = null;
fix = delegate()
{
if (InvokeRequired)
{
Invoke(fix);
}
else
{
buttonAdd_Click(null, null);
}
};
var thread = new Thread(fix);
thread.Start();
}
The buttonAdd_Click method adds an item to a ListView. Strangely, I avoid this error if I add a breakpoint to the if (InvokeRequired)
line. This is very similar to a pattern I have written dozens of times, I suspect I am missing something due to new baby no sleep syndrome.