Inadequate code to really see your problem. However, I would wrap the code you execute in the perform click in a method, then call the method when you need to execute that code. If you really want to execute the click method, execute it directly, not through the button. If the event handler for the button is
button1_Click
, then just execute the
button1_Click
:
button1_Click(this, new EventArgs())
.
or
button1_Click(button1, new EventArgs())
Doing this eliminates the need for the button to be in a state that it can be executed, and also eliminates most potential threading problems.