G
Guest
In the form cs:
form()
{
Thisfrm = this;
}
....
....
public delegate void delegateWriteDetail (string str);
private void WriteDetailScreen(string str)
{
delegateWriteDetail updateDelegate = new delegateWriteDetail (WriteDetail );
Thisfrm.BeginInvoke (updateDelegate, new object[] {str});
}
private void WriteDetail (string str)
{
this.txtDetail.Text = str + "\r\n" + this.txtDetail.Text;
}
When I call WriteDetailScreen method that will call BeginInvoke method to let the UI thread update the screen. Something, the WriteDetailScreen method may be called by the same UI thread for the form or called by other threads. When the program is running, the screen is updated properly but I find that I sometime get the error message when call the WriteDetailScreen method. The error is below:
"Invoke or BeginInvoke cannot be called on a control until the window handle has been created"
Why?
How to solve it?
form()
{
Thisfrm = this;
}
....
....
public delegate void delegateWriteDetail (string str);
private void WriteDetailScreen(string str)
{
delegateWriteDetail updateDelegate = new delegateWriteDetail (WriteDetail );
Thisfrm.BeginInvoke (updateDelegate, new object[] {str});
}
private void WriteDetail (string str)
{
this.txtDetail.Text = str + "\r\n" + this.txtDetail.Text;
}
When I call WriteDetailScreen method that will call BeginInvoke method to let the UI thread update the screen. Something, the WriteDetailScreen method may be called by the same UI thread for the form or called by other threads. When the program is running, the screen is updated properly but I find that I sometime get the error message when call the WriteDetailScreen method. The error is below:
"Invoke or BeginInvoke cannot be called on a control until the window handle has been created"
Why?
How to solve it?