I have a program that can open multiple forms, and when there are a lot of them, they cascade when they are opened.
When a button is pressed, some code runs and the form clos开发者_运维问答es
this.Visible = false; Kill.Zombies(); this.Close();
My Kill.Zombies(); method takes a few seconds to run, so I make the form invisible before running it. The problem I'm having is that even when it's invisible, the forms behind it don't refresh, and it's as if the form that should be invisible is still visible.
I try moving the form before making it invisible, and it still has the issue of showing up on top of forms behind it.
If you could give me some advice on how to fix this, I'd appreciate it.
Do you call Application.DoEvents() after this.Visible = false; ?
The proper way to do it would be multithreaded, but a call to DoEvents() might fix it.
this.Visible = false;
MethodInvoker mk = delegate {
Kill.Zombies(); this.Close();
};
mk.BeginInvoke(null,null);
use above code.
精彩评论