How do i check if an instance of the form already exists?
Im developing a plugin for Rhino, and when i run the command starting plugin i carries out the following. It creates a splash form, which has a timer on it, and after 2sec i loads another form.
If i by mistake click the plugin-icon again, it creates another instance of the spash form, which loads the plugin again.
How do i prevent this?
This is the code that makes the form.
public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
{
Splash Splash = new Splash();
Splash.Show();
开发者_Python百科 return IRhinoCommand.result.success;
}
public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
{
if (!Application.OpenForms.OfType<Splash>().Any())
{
new Thread(() => Application.Run(new Splash())).Start();
}
return IRhinoCommand.result.success;
}
精彩评论