Click here to Skip to main content
15,911,360 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey guys, i'm using vs2005, and i have got a filesystemwatcher, and in the change event of filesystemwatcher i'm displaying a form, but the problem is that whenever the change event is fired, the form get displayed and it gets hanged, don't know why? can anyone help me please? here is the code

Posted
Comments
CodingLover 28-Sep-11 6:20am    
Is that your application running on a single thread or multiple?

By the time we cannot see your code. ;)
savp 28-Sep-11 6:24am    
in a single thread, "the main thread"
CodingLover 28-Sep-11 6:31am    
That's not good actually. You better deals with multiple threads. If you want to communicate across all forms, this way really kills you.
savp 28-Sep-11 6:26am    
here is the code
private void fws_Changed(object sender, FileSystemEventArgs e)
{

Form2 frm = new Form2();
frm.Show();
}
CodingLover 28-Sep-11 6:33am    
Is this hang your main form or the child?

Thats because the events are not raised asynchronously, so you'll have to either use Form.Show instead of Form.ShowDialog or start a new thread where display the form and do any work you like. If you make use of a new thread remember the apartment must be STA.
 
Share this answer
 
Comments
savp 28-Sep-11 6:33am    
but how can i use Form.Show() without creating an instance??
Simon Bang Terkildsen 28-Sep-11 6:46am    
You can't, you'll ofcouse have to create an instance of your form.
Since you are running the application in a single thread, the form itself could block the initialization child form. Try to initialize first of all.
 
Share this answer
 
Comments
savp 28-Sep-11 6:39am    
i have initialize it but still not working, but if i run the same piece of code in different machine it is working fine!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900