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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Jan 15, 2015, 9:45 AM
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.