Hi all,
I am currently building an application for processing dgn files using IPC (inter-process communication) method. Everything seems to be working quite nicely except for when a modal dialog is created that will block the current thread, preventing processing from continuing execution.
Has anyone found any methods for closing out modal dialogs when they are opened? Here's what I have tried so far:
//1: Application event watcher to detect when the active thread is in a modal state Application.EnterThreadModal += Application_EnterThreadModal; ... //2: Monitor open forms as backround task (since modal will block current thread) private void Application_EnterThreadModal(object sender, EventArgs e) { Task.Run(() => CheckForms()); //Run as background task } private static void CheckForms() { Thread.Sleep(1000); //Delay to allow form to load System.Windows.Application.Current.Dispatcher.Invoke(() => { //1: Fails - no entry point found in stdmdlbltin.dll? IntPtr current = MdlWrappers.mdlDialog_getFirst(); while (current != IntPtr.Zero) {//Cycle through dialogs (not working) if(MdlWrappers.mdlWindow_isModal(current)) { current = MdlWrappers.mdlDialog_getNext(current); int close = MdlWrappers.CloseCommandQueue(); //Not sure if this works yet } } //2: Works - but no modal windows found IntPtr current = MdlWrappers.mdlWindow_getFirst(); while (current != IntPtr.Zero) {//Cycle through available windows (working) if(MdlWrappers.mdlWindow_isModal(current)) { int close = MdlWrappers.mdlWindow_close(current, 2, false); //Not sure if this works yet } current = MdlWrappers.mdlWindow_getNext(current); } }); }
I also just found this article but it seems a bit outdated: https://communities.bentley.com/products/microstation/w/askinga/440/keyins-to-toggle-dialogs-and-toolboxes-pre-v8 - perhaps there is a similar option to this to find and then close them out via keyin?
Thanks,
Edward