0

I've a context menu with another drop-down context menu, on the second context menu each item has a tooltip (setted with toolStripMenuItem.ToolTipText):

enter image description here

When I click an item, I start some computing-intensive operations, but just before I call Hide() on the first context menu:

ctxMainMenu.Hide()
// computing-intensive statements

The two menus disappear correctly, but the tooltip remains on top, until subsequent operations end.

I already tried Application.DoEvents(), setting clicked item's tooltip text to null etc

Sometimes, if I click before it paints completely, just a shadow or the faded tooltip appears. enter image description here

Teejay
  • 7,210
  • 10
  • 45
  • 76
  • My guess is that since there was no MouseLeave event, due to your hiding of the menu, the ToolTip waits for its timeout before disappearing, but is subsequently delayed because you're locking up the GUI before that happens. – Justin Ryan Nov 12 '14 at 09:55
  • Have you tried using the `Hide` method of the tooltip before the intensive task? – Tea With Cookies Nov 12 '14 at 09:57
  • The right way to resolve this issue is to do the computing-intestive statements in a separate thread and not lock down your GUI thread, that is ofc if it is possible to do so. – Bernd Linde Nov 12 '14 at 09:58
  • @TeaWithCookies I cannot access the tooltip, since it's an automatic tooltip: `toolStripMenuItem` has no `ToolTip` property, just `ToolTipText` and `AutoToolTip`. – Teejay Nov 12 '14 at 10:13
  • Deadlocking the GUI thread never produces desirable outcomes. Everything is frozen solid until it stops executing that expensive code. You need to move it to a worker thread, use the Task or BackgroundWorker classes. – Hans Passant Nov 12 '14 at 10:14
  • @BerndLinde Yes, I know that, but it only takes a few seconds, so it's not so bad for the user. – Teejay Nov 12 '14 at 10:14
  • @HansPassant As I just said, I know that, but in this case simply the game is not worth the candle. Also I need to work with UI objects so I would have to wrap all calls to the UI thread, in order not to have a cross-threading operation exception. – Teejay Nov 12 '14 at 10:17
  • Well, if it is not worth it then that UI flaw can't be that important either. Set your priorities correctly. – Hans Passant Nov 12 '14 at 10:22
  • @HansPassant There is `Hide()` that works perfectly for the ctx menu, I was just asking if there is something similar for the tooltip. I don't want to rewrite the software for a stupid thing, I'd rather remove the tooltip instead. – Teejay Nov 12 '14 at 10:44

0 Answers0