Add-in Express Regions for Microsoft Outlook issue

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

Add-in Express Regions for Microsoft Outlook issue
Outlook regions are not showing correctly 
Andriy


Guest


Hello,
We have an add-in that shows region over emails list, it works perfectly. But our customers see strange behavior, when outlook starts, our region does not contain switch arrows.
[img]https://imgur.com/a/gTVGpwU[/img]

We have detected that the reason of this behavior is a conflict with another add-in. Also we have contacted developers of this addin and identified exact line of code which coused this issue, this is 'System.Windows.Forms.Application.DoEvents();' call on addin startup. By the link below you can find test add-ins to duplicate this issue:
https://drive.google.com/open?id=1hk7wyqv6ScMpTcn4TEjciwNb0NCLnEE-

How can we fix this issue?
Posted 03 Jan, 2019 08:43:53 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Andriy,

Using DoEvents in an add-in opens a door to all sorts of problems. You should understand that an add-in is built on events; each event only occurs when the corresponding window message is sent to the host application's window. When you call DoEvents, you postpone executing the event handler of the current event in order to let the host application read all other messages; some of the messages show/hide/resize the window, this produces other events that your code handle; among the events processed there may be the event just postponed. This creates a mess to survive in which may be impossible. Say, commandbar controls and Ribbon controls may work incorrectly if DoEvents is used in code.

The issue that you experience obviously depends on the order in which these or those Window messages are sent to Outlook windows. I assume some message(s) is handled prematurely or too late. The real problem is: this depends on the machine, its performance and environment. No solution exists for this scenario. You need to stop calling DoEvents. Use a System.Windows.Forms.Timer object if you need to wait for something.


Andrei Smolin
Add-in Express Team Leader
Posted 03 Jan, 2019 09:13:12 Top
Andriy


Guest


Unfortunately I can not force development team of this addin to stop using DoEvent, also we may have other add-ins which use the DoEvent on starting and will couse the same behaviour.

We have checked this several machines, and on our side we always have the same result - panel without arrows (In case two of test add-ins are enabled). So for me this looks like call DoEvent on starting always couses this issue, have you checked provided add-ins on your side?
Posted 08 Jan, 2019 05:19:01 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Andriy,

DoEvents is a no-go! https://www.google.com/search?client=firefox-b&q=Is+DoEvents+Evil

As explained the issue depends on the order in which window messages are handled. If no DoEvents exists, all of them will be handled in the FIFO order. If DoEvents is used, the window procedure behind the window handles all messages from the message queue and returns control to your method. There can be no solution in this case as this breaks the inner logic of Add-in Express in an unpredictable fashion. Even if you see some regularity in your tests, the actual order of messages depends on the environment: other add-ins, processor speed, work load, etc.

I'd like that you check this specific article: https://blogs.msdn.microsoft.com/jfoscoding/2005/08/06/keeping-your-ui-responsive-and-the-dangers-of-application-doevents/.


Andrei Smolin
Add-in Express Team Leader
Posted 08 Jan, 2019 06:08:15 Top