Long delay adding an item to the context menu

S

Stuart Leeks

I've written an outlook addin using ATL but have got an unusual performance
problem.

I'm handling the CommandBarEvents OnUpdate and in my event handler I create
a popup menu on the context menu. Under certain situations this performs very
badly. I've added tracing and the Controls->Add method on the context menu
command bar takes 5 seconds or more.

The problem generally only happens when you switch focus from outlook to
another application and then switch back. Is there something I can check to
avoid creating the context menu in this case? Does anyone have any ideas why
this call should take 5 seconds?

Any help would be appreciated!
 
A

Ariel

Hey Stuart.

(First and foremost - if you could share your code here - that'll be
great)
The timeframe of five seconds makes me thing of "bigger" things: is
this call the first time you access any external dlls? Office.dll?
Outlook.dll? (interops)
We had a similar problem and located the delay at the assembly loader.
(If this happens everytime you call this method then I guess I'm way
off)


Ariel
 
S

Stuart Leeks

Hi Ariel.

Thanks for replying.

The code that I'm using is:

****
Office::CommandBarPtr spContextBar;
CComVariant vtTypePopup(msoControlPopup);
CComVariant vtFalse(false);
// ...
spControlPtr = spContextBar->Controls->Add(vtTypePopup, 1, vtMissing,
vtMissing, vtFalse); // This line takes 5s to execute when switching focus to
Outlook

This isn't the first time that I've made the call. The add in works fine
until you switch focus to another window and then switch back to the main
outlook window. At that point the OnUpdate event fires, my code adds the menu
items to the context menu and hits this delay.

Any ideas welcome!
 
A

Ariel

Hey Stuart.

Is it possible that you add the button to the wrong command bar? The
"CommandBars" object differs for each time the event raises, so maybe
you hold the wrong CommandBar object, and cause some lengthy operation?
(I'm shooting in the dark)


Ariel
 
S

Stuart Leeks

I'm keeping hold of a reference to the context menu bar once I've got it, so
I'm using the same reference each time.

Thanks for replying - keep the ideas coming!

Stuart
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top