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
Edward Ashbolt said:I am currently building an application for processing dgn files using IPC (inter-process communication) method
MicroStation is almost irrelevant here! Yours is a general question about writing .NET IPC classes. Consult a website that deals with advanced .NET development. For example, StackOverflow.
Regards, Jon Summers LA Solutions
Actually the bit that I'm struggling with is entirely MicroStation - whenever MicroStation launches a dialog box I want to close it programmatically. Looking at the .NET API it seems there is limited support for working with dialogs etc. however the native API has some classes that seem appropriate, however I am yet to see success with them. I was hoping that perhaps someone else has come across a solution to this problem within the MicroStation API