Why do modal dialogs that are opened through a menu item’s click event process all wi
So for the past day or so I have been fixing a bug that is caused by a modal dialog. I work on an application which communicates with the server through the Windows message pump. When I use ShowDialog() to show a modal form, the message pump is blocked and none of my messages are processed, yet they do build up in the queue (expected behavior).
However, I recently noticed that if a modal form is opened through a menu item's click event, the messages are pumped to the main form and processed. Does anyone know why these messages are not blocked when a modal form is shown through a menu item's click event?
Re: Why do modal dialogs that are opened through a menu item’s click event process all wi
Try opening the modal dialog like this:
Code:
form.ShowDialog(this);
Re: Why do modal dialogs that are opened through a menu item’s click event process all wi
So, I suppose I should have mentioned that I am already doing that. Thank you for your reply though, this is the first one I have got over three different forums.
Re: Why do modal dialogs that are opened through a menu item’s click event process all wi
Why do you use message loop to communicate with the server? It seems to me as not a good idea. Could the communication run in its own thread without a message loop? Than no blocking should occure. If you are using poll model, I think that common Timer should work fine.
Re: Why do modal dialogs that are opened through a menu item’s click event process all wi
Well, that is true. It would be better to use a receive thread and a send thread to do this, but that is not the application that I have inherited and there isnot enough time in this release to change this. We do plan on changing this behavior soon, but in the meantime I really just need to figure this one out. I have a workaround that I do not like and I really just want to understand what is special about the click event of a menu item.
Re: Why do modal dialogs that are opened through a menu item’s click event process all wi
the thread that creates aparticular control owns the message pump for it. is there any chance that your dialog or the menu is using a thread other than the main window thread, for creation of the dialog?
Re: Why do modal dialogs that are opened through a menu item’s click event process all wi
So, I think that the problem is in my application (sorry). I found some code deep down in the guts of the app that was preventing messages from being processed, even though they were being queued. Thanks everyone who tried to help here, I presented a problem that does not really make sense. Sorry for wasting your time, and thanks again.