c# - Block closing WPF window (from a different thread) if OpenFileDialog is open -
to clear things before mention obvious choice, calling showdialog , not show method!!! i block close (invoked different thread) off wpf window if openfiledialog open. here code have (reduced show problem): public class foowindow : window { public foowindow() { initializecomponent(); this.closing += onclosing; } public void opendialogandcloseme() { var ofd = new openfiledialog(); thread th = new thread(() => closeme()); th.start(); ofd.showdialog(this); } public void closeme() { system.threading.thread.sleep(2000); //give openfiledialog time pop up... //since method gets called different thread invoke it... this.dispatcher.invoke(() => this.close()); } private void onclosing(object sender, canceleventargs e) { //check if openfiledialog still open , block close... e.cancel = true; } } the problem facing onclosing part, how ope...