c# - Winform freezes when I try to close it -
i have following code
private void btnclose_click(object sender, system.eventargs e) { close(); } // btnclose_click after running close winforms function application freezes. idea why can happen?
i use .net 2.0 , run under windows 7 vs2005
edit:
after pressed pause in debugger came
private void mainform_closing(object sender, system.componentmodel.canceleventargs e) { // gui if (fscannerthread_running) { fscannerthread_running = false; fscannerthread.join(); } } and stacked in fscannerthread.join(); idea how can kill ?
use bool thread.join(int milliseconds) overload, , if result false, abort() thread.
private void mainform_closing(object sender, system.componentmodel.canceleventargs e) { // gui if (fscannerthread_running) { fscannerthread_running = false; if (!fscannerthread.join(1000)) // give thread 1 sec stop { fscanner.abort(); } } } note should catch threadabortexception in thread in order end gracefully (if have release instance).
Comments
Post a Comment