There is a nasty bug in the implementation of Application.OpenForms, you should avoid relying on it. This code shows the bug at work:
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e) {
this.ShowInTaskbar = !this.ShowInTaskbar;
MessageBox.Show("Number of open forms: " + Application.OpenForms.Count);
}
}
This info is courtesy of
Hans Passant.