none
Delay load of Add-in

    Question

  • Hi,

     

    I have an Outlook addin created using VS 2010. It has a lot of menu items and images to be displayed. Whenever i start Outlook 2010, it takes a long time to load my addin (i can see the name of my addin while outlook is loading it). Is there a way by which i can reduce the load time ?

    I have checked my add in by commenting the code which initializes the UI and as soon as i do that the loading of the addin is just instantaneous. However, i cant change the menus as they are part of the feature.

    I am thinking this way. Is there a way by which i load the UI of my addin only when somebody clicks on "Add-ins" ribbon ?

     

    Thanks


    Kulvinder Singh
    Friday, April 01, 2011 11:10 AM

Answers

  • There are a few ways.
     
    One is to grab the current thread context in an Outlook event after priming the message pump (System.Windows.Forms.Application.DoEvents()) and store that and use a SendOrPost() call from your context to the Outlook thread context.
     
    The simplest way is probably to set up a hidden Windows Form on startup and put a timer control on it. That should fire in the main thread, but I'd check it out to make sure.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Kulvinder" <=?utf-8?B?S3VsdmluZGVy?=> wrote in message news:4bab4f56-ff58-47f7-a872-646075f97126...
    SO, how do i switch over to the Outlook thread from a secondary thread like timer ?
    Kulvinder Singh

    Ken Slovak MVP - Outlook
    Friday, April 01, 2011 1:26 PM

All replies

  • I'm not sure what type of addin you have created, but check out the 'LoadBehavior' section on this page:-

    http://msdn.microsoft.com/en-us/library/bb386106.aspx

    Alan Moseley

    Friday, April 01, 2011 12:31 PM
  • The ribbon calls for initialization come when they come, you can't control that. In 2010 they are very soon as the Explorers have ribbons.
     
    Much of your initializations can be delayed somewhat by waiting for the Namespace.AutoDiscoveryCompleted() event to fire, but that's mainly an Exchange thing. Otherwise you might want to look into a timer control to delay your other initialization for a bit after startup.
     
    Of course as the Outlook object model is not suitable for use in a background thread you would need to synch the context of the timer thread back to the main Outlook thread before you use the object model in the timer event handler.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Kulvinder" <=?utf-8?B?S3VsdmluZGVy?=> wrote in message news:06bcebdd-e68f-48e0-b389-f0cd2500f8dd...

    Hi,

     

    I have an Outlook addin created using VS 2010. It has a lot of menu items and images to be displayed. Whenever i start Outlook 2010, it takes a long time to load my addin (i can see the name of my addin while outlook is loading it). Is there a way by which i can reduce the load time ?

    I have checked my add in by commenting the code which initializes the UI and as soon as i do that the loading of the addin is just instantaneous. However, i cant change the menus as they are part of the feature.

    I am thinking this way. Is there a way by which i load the UI of my addin only when somebody clicks on "Add-ins" ribbon ?

     

    Thanks


    Kulvinder Singh

    Ken Slovak MVP - Outlook
    Friday, April 01, 2011 1:06 PM
  • SO, how do i switch over to the Outlook thread from a secondary thread like timer ?
    Kulvinder Singh
    Friday, April 01, 2011 1:14 PM
  • There are a few ways.
     
    One is to grab the current thread context in an Outlook event after priming the message pump (System.Windows.Forms.Application.DoEvents()) and store that and use a SendOrPost() call from your context to the Outlook thread context.
     
    The simplest way is probably to set up a hidden Windows Form on startup and put a timer control on it. That should fire in the main thread, but I'd check it out to make sure.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Kulvinder" <=?utf-8?B?S3VsdmluZGVy?=> wrote in message news:4bab4f56-ff58-47f7-a872-646075f97126...
    SO, how do i switch over to the Outlook thread from a secondary thread like timer ?
    Kulvinder Singh

    Ken Slovak MVP - Outlook
    Friday, April 01, 2011 1:26 PM