G
Guest
Hello,
I am writing a program in Visual C# and I have encountered a problem.
In my program I want to dynamically create a multitude of controls (thousands) on a form. The problem is that calling the Controls.Add() method several times or even calling the Controls.AddRange() method once can take a huge amount of time. Therefore, I would like to be able to run the loop that creates the controls on a different thread and meanwhile give the user a progress indicator dialog with an option to abort the operation. The probelm is that when I try to use the Controls.Add() method within the new thread I get a runtime error that states: "Additional information: Controls created on one thread cannot be parented to a control on a different thread." What should I do?
Thanks for your help,
Aviv.
I am writing a program in Visual C# and I have encountered a problem.
In my program I want to dynamically create a multitude of controls (thousands) on a form. The problem is that calling the Controls.Add() method several times or even calling the Controls.AddRange() method once can take a huge amount of time. Therefore, I would like to be able to run the loop that creates the controls on a different thread and meanwhile give the user a progress indicator dialog with an option to abort the operation. The probelm is that when I try to use the Controls.Add() method within the new thread I get a runtime error that states: "Additional information: Controls created on one thread cannot be parented to a control on a different thread." What should I do?
Thanks for your help,
Aviv.