# Global async acq crashes my application?!

**URL:** <https://forum.commonvisionblox.com/t/global-async-acq-crashes-my-application/78>\
**Category:** C-style API\
**Tags:** visualbasic, acquisition, multithreading\
**Created:** [May 15, 2017, 8:47am UTC](https://forum.commonvisionblox.com/t/global-async-acq-crashes-my-application/78 "2017-05-15T08:47:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BaerTram](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/baertram/32/54_2.png) [@BaerTram](https://forum.commonvisionblox.com/u/BaerTram)\
**Post date:** [May 15, 2017, 8:47am UTC](https://forum.commonvisionblox.com/t/global-async-acq-crashes-my-application/78/1 "2017-05-15T08:47:53Z")

</div>

Hi, I’m using CVB with VB6. Currently I have a simple acquisition application that captures from two cameras simultaneously. I would now like to process the images from both cameras independent from each other while capturing. I’ve read in the manual that there is a “global async acq” flag that should enable me to do what I want.  
But, whenever I have the flag enabled my application crashes. Are there any additional things that I could have missed in order to use the global async acq?

---

<div class="post-metadata">

**Author:** ![illusive](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/illusive/32/61_2.png) [@illusive](https://forum.commonvisionblox.com/u/illusive)\
**Post date:** [May 15, 2017, 9:56am UTC](https://forum.commonvisionblox.com/t/global-async-acq-crashes-my-application/78/2 "2017-05-15T09:56:41Z")

</div>

Hi @BearTram

The “Global Async Acq Enabled” flag is generally problematic, and under Visual Basic 6 especially so. “Global Async Acq Enabled” changes the way the `ImageSnaped` (sic! sorry for the typo…) event is propagated from the image control to the application. If “Global Async Acq Enabled” is _ **not** _ set, then the `ImageSnaped` event will be processed in the application’s UI thread, whereas if it is set, then it will be processed in the context of the image control’s acquisition thread.

The implications of that difference are far ranging: If “Global Async Acq Enabled” is set, accessing user interface components will usually lead to undefined behavior regardless of the programming language being used (the only safe and permissible way to access UI components in this scenario are through `SendMessage`/`PostMessage`, or - in the case of a Windows Forms application - through `Invoke`/`BeginInvoke`).

One of the restrictions of Visual Basic 6 is that it does not directly support multithreading, so in Visual Basic 6 no safe option for accessing user interface components when “Global Async Acq Enabled” has been set is available and on top of that, with the “Global Async Acq Enabled” option set the Visual Basic 6 debugger is known to crash if a breakpoint is set in the `ImageSnaped` handler.

For these reasons, starting with Common Vision Blox 12 the Global Async Acq Enabled flag has been removed from the Common Vision Blox Management Console, but the flag is still accessible through the _CVCUtilities.dll_ functions `SetGlobalAsyncACQEnabled` and `GetGlobalAsyncAcqEnabled` (kudos for finding them in the documentation!).

As a more general remark: Please consider switching to a more modern development environment. I know it is not my place to question your choice of programming languages, and I certainly do not want to push you into any particular direction. However, mainstream support for Visual Basic 6, a product released in 1999, officially ended in April 2005 (extended support in March 2008) and still using it 10+ years on has tangible disadvantages (friction with the UAC on post-XP Windows operating systems, vulnerabilities in the runtime). For example [VB.Net](http://VB.Net) offers a very similar syntax, a similarly easy composition of UIs and at the same time provides access to multi threading.

---

<div class="post-metadata">

**Author:** ![BaerTram](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/baertram/32/54_2.png) [@BaerTram](https://forum.commonvisionblox.com/u/BaerTram)\
**Post date:** [May 16, 2017, 7:22am UTC](https://forum.commonvisionblox.com/t/global-async-acq-crashes-my-application/78/3 "2017-05-16T07:22:21Z")

</div>

Yeh, I know, VB6 is kind of outdated. 😳 I’ll see if I can switch to VB Net. Anyhow, thank you for the explanation!
