Re: Delegate.BeginInvoke and EndInvoke.
"Bhatnagar, Amit" <[email protected]> Thu, 17 Jan 2008 08:44:06 -0700
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <[email protected]> |
Thanks Peter for looking into this. Well what I don't get is that it never hangs during my app's initialization (where we get the current NC metrics), nor does it hang when I minimize the app (where I restore the NC metrics). The only call that causes it to hang is during shutdown. I have tried moving this from my MainWindow's FormClosing event out into a call just after RunApplication() returns, but that also sometimes hangs (process still lives, main window is gone.) Isn't that odd? Shouldn't the window be destroyed by the time we return from RunApplication() and thus no messages should cause a hang? Either way, running the call on a async delegate at least lets my application to close, and I am not too worried that the delegate may not return and cause a thread from the pool to hang because the application is closing anyhow. Not the best way to do things, but it'll do for now.=20 Do you know if .NET 3.5 has a better way of doing things? Is there finally a .NET API to access these system settings? -----Original Message----- From: Discussion forum for developers using Windows Forms to build apps and controls [mailto:[email protected]] On Behalf Of Peter Ritchie Sent: Wednesday, January 16, 2008 7:19 PM To: [email protected] Subject: Re: [DOTNET-WINFORMS] Delegate.BeginInvoke and EndInvoke. The documentation for SystemParametersInfo details sending the cbSize value for SPI_{G|S}ETCLIENTMETRICS; but I tried with 0 and it seems to work too (the same value is in NONCLIENTMETRICS, so it doesn't *need* it). Okay, a little bit of testing shows that SystemParametersInfo (at least with SPI_SETCLIENTMETRICS) is blocking, but it doesn't block the GUI thread and it continues to pump messages. In my test, while blocked on the SystemParametersInfo(SPI_SETCLIENTMETRICS) the thread received the following messages: WM_WINDOWPOSCHANGING WM_GETMINMAXINFO WM_NCCALCSIZE WM_WINDOPOSCHANGED You can certainly get in a situation--since a function call is blocked and messages can come in on the same thread while that's blocked--where you can cause a hang. The information contained in this e-mail message is PRIVATE. It may = contain confidential information and may be legally privileged. It is = intended for the exclusive use of the addressee(s). If you are not the = intended recipient, you are hereby notified that any dissemination, = distribution or reproduction of this communication is strictly = prohibited. If the intended recipient(s) cannot be reached or if a = transmission problem has occurred, please notify the sender immediately = by return e-mail and destroy all copies of this message.=20 Thank you.=20