My WinForms App Needs a Loading Panel. I am using the example found here
(flowLayoutPanel1 is on the UI Thread The async delegate code that replaces Thread.Sleep in the example is similar to code below. I get cross thread errors adding my dynamic control to the flow panel)
AsyncProcessDelegate d = delegate() {
flowLayoutPanel1.Controls.Clear();
Panel p1 = new Panel();
Button btn1 = new Button();
p1.Controls.Add(btn1);
//tried to access from another thread
flowLayoutPanel1.Controls.Add(p1);
// Just in case it's not clear, I already know this does not work
// The question is how can I make the example wait for my UI to load
// if I can't do the dynamic control creation as shown.
};
RunAsyncOperation(d);