Error: Cross-Thread exeption.
I found many exaples how to modify a control from another Thread but i cant close the Form (a simple StatusForm) from the The MainForm. What im trying to do is to close the form inside a void "AsyncCallback" wich is called by a Thread.
I would appreciate your Help
Reggards.
Jose L. Yanez R.

Close a form from another thread?
PhilipHaugaard
Ok... I dont understand what you are telling me, maybe you dont understand me either.
The code speak for itself. ^_^ better then I
Form2 FormStatus = new Form2 ();
private void DoSomething()
{
}
private
void Cuadra(){
}
private
void HandleCallback(IAsyncResult result){
}
Reva
public delegate void CloseDelagate();
Add this line before Form2 class. To close form, you need form reference. If it is called "FormStatus", instead of:
FormStatus.Close();
write:
FormStatus.Invoke(new CloseDelegate(Form2.Close));
Damir Dobric
delegate void CloseDelagate();
Having Form reference in another thread, you can close it by the following way:
form.Invoke(new CloseDelegate(form.Close));
mveeravagu
Jesper L. Nielsen
Alex Farber & ahmedilyas thank you! i start to read again and now i understand very well.
Kiwi_Ant
take a look, particular to my answer, on how to Invoke the UI from another thread:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=564275&SiteID=1