It happens that occasionally two instances of AB are running, one being invisible, except for the second icon in the Task Bar. As outlined in the above referenced post this seems to interferes with OLE functions like zooming - there is no error but the functions do not work.
In the case of zooming I can see they don’t work but in other applications OLE failure may go undetected. If this happens during trading there could be consequences. fwiw, Google showed me that I asked this question 10 years ago, so it seems that some of us go full-circle I also noticed some other familiar names: it is nice to see you are still around!
Are there any authoritative guidelines on how to run multiple instances of AB safely and/or how to prevent/detect forgotten instances. I know to use separate databases and data providers, or use local data. I solved that with separate AB icons each with a different default db.
Is there a way to detect and raise an alert if an invisible/inactive instance is running?
Windows Task manager and tasklist command line program would show you running instances. You need to keep in mind that if you have both 32-bit and 64-bit versions installed on your machine then they act as separate OLE objects and 32-bit callers control only 32-bit AmiBroker while 64-bit callers run only run 64-bit AmiBroker. If you are calling from outside programs then care must be taken about bitness of the program as described in KB: http://www.amibroker.com/kb/2015/01/12/ole-automation-scripts-with-32-and-64-bit/
I didn’t know about the TaskList… Some Googling showed that it would get rather complicated (for me) to write code to read/parse this list. Also seeing the instances wouldn’t show which version is which?
The simplest solution would be to execute (only when needed) a test OLE that returns a flag, or creates a file used as a flag, to show it executed properly. This would prove OLE is executing properly. If the file wasn’t created I could generate an alert, if it was created I simply delete it knowing all is OK.
This would be a useful utility. The question now is what would be the simplest OLE code that performs a task that can be verified from afl?
Would this work? Any OLE experts reading this who have an idea?