ADXOutlookItemEvents.ConnectTo can take up to few seconds

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

Only registered users are allowed to subscribe.
ADXOutlookItemEvents.ConnectTo can take up to few seconds
Performance issue when connecting to events in outlook 2007 
Subscribe
Gutek Jakub




Posts: 8
Joined: 2017-06-06
We are having small problem in one of our applications. After some time of using Outlook one user (currently one from around 100) is experiencing performance issue with outlook when he switch between applications.

By detailed trace we have found that line:


// _itemEvents => OutlookItemEventsClass : AddinExpress.MSO.ADXOutlookItemEvents
_itemEvents.ConnectTo(mail, true);


is taking longer and longer to execute. Its stars with few milliseconds and goes up to few seconds (max was 3). During execution of that ConnectTo outlook is unresponsive. Restarting outlook fix issue for some time.

ConnectTo is always executed after checking if IsConnected and RemoveConnection. I was even trying to optimize this with checking if currently connected item is the same that i want to connect, just to not to do too many ConnectTo, but it didn't help:

public bool Reconnect(object item, bool release)
{
    if (item == this.ItemObj)
    {
        return true;
    }

    if (IsConnected)
    {
        RemoveConnection();
    }

    // this line takes up to few seconds
    bool connected = ConnectTo(item, release);

    return connected;
}


This happens in Outlook 2007.

Any ideas what we can do/make to fix this problem?

Thanks!
Posted 07 Sep, 2017 08:40:35 Top
Andrei Smolin


Add-in Express team


Posts: 14094
Joined: 2006-05-11
Hello Gutek,

I don't think that the cause of the issue is located in the code of Add-in Express. Check if the issue is reproducible with other COM add-ins turned off; if you have Microsoft VBA for Outlook add-in, don't turn it off. Also, I'd check if turning the antivirus off solves the issue.

If the above doesn't help, check if using VBA to connect to events produces the same issue. Open the VBA IDE in Outlook (Alt+F11), and paste the code below to the ThisOutlookSession class:

[CODE]Dim WithEvents itm As Outlook.MailItem

Sub startWorking()
Debug.Print "startWorking 1: " + CStr(Now)
'Set itm = Application.ActiveInspector.CurrentItem
Set itm = Application.ActiveExplorer().Selection.Item(1)
Debug.Print "startWorking 2: " + CStr(Now)
End Sub

Sub stopWorking()
Set itm = Nothing
Debug.Print "stopWorking"
End Sub

Private Sub itm_Forward(ByVal Forward As Object, Cancel As Boolean)
Debug.Print "itm_Forward"
End Sub[QUOTE]

The code above connects to events of the selected item; it reports all actions to the Immediate window (menu View | Immediate Window). It handles the Forward event simply to illustrate that the events are connected.

Now, test your add-in and when the delay becomes too big, execute the startWorking method: put the text cursor on any line of the method and press {F5}. Does this work with the same delay?

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 07 Sep, 2017 10:21:42 Top
Gutek Jakub




Posts: 8
Joined: 2017-06-06
Thanks, i have asked user to do test with other plugins. We know that disabling our plugin solves this issue.

Moreover (i'm waiting for confirmation) this only happens once when you switch from other application to outlook. So outlook is minimazed/in background, and user from i.e. Excel with ALT+TAB or click switch to Outlook.

I will come back with answers i've got from tests. Once again thanks for the idea to check with other add ins off.
Posted 07 Sep, 2017 10:50:55 Top
Andrei Smolin


Add-in Express team


Posts: 14094
Joined: 2006-05-11
Please keep me informed.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 08 Sep, 2017 05:18:43 Top