plugin load time with Add-in Express Regions generated code

Add-in Express™ Support Service
That's what is more important than anything else

plugin load time with Add-in Express Regions generated code
 
Sharon Tourjeman




Posts: 16
Joined: 2017-03-02
I noticed the generated code by Add-in Express Regions slows the plugin load time,
it adds about ~200ms to the plugin init time and this is on my fast computer i believe in slow or old computer it will take more time.
Can i move the code to different thread or make it run after outlook loads?
i don't want the plugin to get disabled because of the load time

the code is:

this.FormsManager = AddinExpress.OL.ADXOlFormsManager.CurrentInstance;
this.FormsManager.OnInitialize += new AddinExpress.OL.ADXOlFormsManager.OnComponentInitialize_EventHandler(this.FormsManager_OnInitialize);
this.FormsManager.Initialize(this);
Posted 21 Jun, 2017 05:09:22 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello Sharon,

You cannot move this code to a thread. Try to start a System.Windows.Forms.Timer in the ThisAddIn_Startup() method and move that code in the timer's event.

Does this work?


Andrei Smolin
Add-in Express Team Leader
Posted 21 Jun, 2017 07:39:06 Top
Sharon Tourjeman




Posts: 16
Joined: 2017-03-02
Hi Andrei,

I tried this:


private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
   System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
   timer.Interval = 2 * 1000;
   timer.Tick += Timer_Tick;
   timer.Start();
}

private void Timer_Tick(object sender, EventArgs e)
{
   #region Add-in Express Regions generated code - do not modify
   this.FormsManager = AddinExpress.OL.ADXOlFormsManager.CurrentInstance;
   this.FormsManager.OnInitialize += new AddinExpress.OL.ADXOlFormsManager.OnComponentInitialize_EventHandler(this.FormsManager_OnInitialize);
   this.FormsManager.Initialize(this);
   #endregion
}

and i got exception on this.FormsManager.Initialize(this); that i tries to do it on garbage collected AddinExpress.Outlook.Regions item

Managed Debugging Assistant 'CallbackOnCollectedDelegate' has detected a problem in 'C:\Program Files (x86)\Microsoft Office\root\Office16\outlook.exe'.

Additional information: A callback was made on a garbage collected delegate of type 'AddinExpress.Outlook.Regions!AddinExpress.Extensions.WindowsAPI+HookProc::Invoke'. This may cause application crashes, corruption and data loss. When passing delegates to unmanaged code, they must be kept alive by the managed application until it is guaranteed that they will never be called.
Posted 21 Jun, 2017 08:01:00 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Sharon,

You should declare the timer variable on the class level. Does this fix the issue?


Andrei Smolin
Add-in Express Team Leader
Posted 21 Jun, 2017 08:05:09 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
You should also stop the timer.


Andrei Smolin
Add-in Express Team Leader
Posted 21 Jun, 2017 08:06:40 Top
Sharon Tourjeman




Posts: 16
Joined: 2017-03-02
no,
still the same exception:
Managed Debugging Assistant 'CallbackOnCollectedDelegate' has detected a problem in 'C:\Program Files (x86)\Microsoft Office\root\Office16\outlook.exe'.

Additional information: A callback was made on a garbage collected delegate of type 'AddinExpress.Outlook.Regions!AddinExpress.Extensions.WindowsAPI+HookProc::Invoke'. This may cause application crashes, corruption and data loss. When passing delegates to unmanaged code, they must be kept alive by the managed application until it is guaranteed that they will never be called.
Posted 21 Jun, 2017 08:25:20 Top
Sharon Tourjeman




Posts: 16
Joined: 2017-03-02
i lowered the the interval to 1 second and now it works,
but i am not sure it will work in any case
Posted 21 Jun, 2017 08:27:57 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Do you stop the timer in the tick event?


Andrei Smolin
Add-in Express Team Leader
Posted 21 Jun, 2017 08:54:57 Top
Sharon Tourjeman




Posts: 16
Joined: 2017-03-02
Yes,
i stop it before the generated code and dispose of it
Posted 21 Jun, 2017 08:59:05 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Sharon,

http://temp.add-in-express.com/support/OutlookAddIn5-ForSharonTourjeman.zip - this project doesn't generate an exception for me.

Outlook 2016 + Add-in Express Outlook Regions 3.3.2345.


Andrei Smolin
Add-in Express Team Leader
Posted 21 Jun, 2017 09:29:30 Top