Hello!
At the moment I'm making an plugin manager application which dynamically imports UserControl(the look-a-likes of panels) dll files.
The main idea is that these plugins will be added each to a new tabpage in a tabcontrol.
Because I want to make sure that the manager will be running smoothly when one of the loaded plugins will be doing an infinite while loop for example.
When this occurs the entire form including all the plugins will be not responding... which is a bad thing.
So my idea was to run these plugins in a separate thread but since I couldn't find anything about it I had small hopes for my only tough:
Creating an instance of the usercontrol object inside a thread, and then add it to a tabpage in a thread safe way (doomed to fail):
private void mrThread()
{
Template.plugin userControl11;
userControl11 = new Template.plugin();
userControl11.Location = new System.Drawing.Point(97, 57);
userControl11.Name = "userControl11";
userControl11.Size = new System.Drawing.Size(452, 393);
userControl11.TabIndex = 0;
AddControl(userControl11);
}
private void AddControl(Control usercontrol)
{
if (this.tabPage1.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(AddControl);
this.Invoke(d, new object[] { usercontrol });
}
else
{
this.tabPage1.Controls.Add(usercontrol);
}
}
Adding the control works in the thread safe way, but unfortunately as I expected, the added control does not act like it's running in a thread.
Probably because it's overloaded?
Perhaps someone has an idea on how to accomplish this? or is it impossible for C#?
I want to make the project opensource (gnu gpl v3), so I won't be able to use propriety software.
Thanks!