C# Application - this.show() and this.hide() causing app to hang
I have a C# app
which I want to run from a tray icon. Basically it shouldn't show in the taskbar when minimised but when the tray icon is double clicked the app window should show as normal.
To achieve this I am using this.Show()
and this.Hide()
which do exactly what I want. The issue I'm having is that for some users when the application is shown, the form appears but none of the UI is drawn correctly and whatever was open below the form s开发者_如何学Chows through. The form becomes totally unresponsive but I can still get it to hide and show by double clicking the tray icon...
If I take the .Show()
and .Hide()
away the application runs with no issues for the users.
I am doing all the UI on the main thread and checking InvokeRequired
to be double sure as I do have a worker thread
but can't fix this issue. Another point is that it doesn't happen all the time and typically only happens after the user's machine has been idle for some time.
I'd really appreciate any help on this. The machines are WinXP using .NET 3.5
and VS2008
When are you calling this.Show and this.Hide ?
Can you compare or try the method detailed at http://www.developer.com/net/net/article.php/3336751/C-Tip-Placing-Your-C-Application-in-the-System-Tray.htm
If this is not done correctly, then I think you can get into a situation where the O/S is confused about a forms state and, for example, may think the form is already shown and hence does not redraw it fully.
精彩评论