this.BeginInvoke(new MethodInvoker(Close));
i have used this method to closing a form but still it gives error
Value Dispose() cannot be called while doing CreateHandle().
thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Jan 15, 2015, 4:45 AM EST
That could happen, for example, if you were calling Close from the form's constructor or its Load event.
In a modeless form (i.e. one displayed with Show rather than ShowDialog), calling Close causes the form's Dispose method to be called.
However, I'm puzzled by the fact that you're using BeginInvoke which suggests you're calling this method from a thread other than the main UI thread.
Does any of that ring any bells with you?
If not, can you explain in what circumstances BeginInvoke is being called.