On some client machines I'm getting this System.ComponentModel.Win32Exception: The operation completed successfully error which apparently indicates resource leakage or hitting the hard limit of 10000 handles per process.
I'm looking through the code to refactor it and the pattern I'm using to create the windows is (simplified)
class MyForm : Form
{
public MyForm()
{
InitializeComponents()
}
//windows generated code
public void InitializeComponents()
{
myButton = new System.Windows.Forms.Button();
myButton.Click += new System.EventHandler(myButton1_Click);
}
private void button1_Click(object sender, EventArgs e)
{
Dispose();
}
}
//this will be called many times throughout the programs lifecycle
Form myForm = new Form()
myForm.ShowDialog();
Is reconstructing the Button each time the window is shown (there are numerous components in reality) likely to cause an issue with handles? I thought that dispose would have meant no but I'm struggling to find other code sections that could be causing the issue.