VB6 how to make an EXE wait for events to complete in DLL -


exe dll flow image

intro

i have dll uses events interact hardware device. in summary, wanting have main exe app wait @ various points while hardware interface dll thing hardware, , passes results main call app, via dll (see image above)

structure of modules

the exe ; simple test app calls various functions in calling dll, in turn calls functions in operating dll. last device dll normal hardware distribution driver type dll manufacturer.

the calling dll ; generic dll various processing apps including dynamically loading various hardware operating dll's required, passing common info translated various , more specific operating dll's. kind of funnel guess.

operating dll ; exists per hardware device connected pc. device such webcam, scanner , on. these dll's written talk generic calling dll @ 1 end, , manufacturers dll @ other end.

summary

i able compile operating dll exe testing. in state has form few buttons. buttons "open" "close" "scan1" "scan2" these same "buttons" called via calling dll when operating dll compiled dll. hope makes sense. in other words, can test operating dll in native mode exe - , runs fine, , can compile dll consumed calling dll.

scan1 , scan2 functions use event handling.

so, operating dll exe , can open , connect device via device dll using internal calls operating dll. work fine, events work, app steps through fine. due guess structure of form layout in operating dll, has per button. still uses events internally externally (at form level) has cycle per button select being scan1 or scan2.

problem

the issue this, when operating dll compiled that, dll, instructions issues calling dll 1 level up. calling dll has code pathway , in there call operating dll tell scan1. that's fine, however, calling dll continues on way , not wait operating dll complete , return required data. therefore calling dll failing. rushing through , not receive data back.

code

this "calling dll - consumes operating dll"

** function used call operating dll , run events ** private function iscandevice_scan1(collections template, byval scanpurpose scanpurposes, byval scantimeout integer, region scanregion) scan_resultcodes  '* call operating dll processes use events  '* scancollected = scan1(collections, scanpurpose, mscantimeout, mregion)   '* following should execute after operating dll stuff completes '*            msgbox ("scan1 call operating dll completed)    call printresults . . end function 

this "operating dll - can compiled exe testing"

option explicit  public withevents obj oposbiometrics      '' ' implements iscandevice interface.  implements iscandevice  . .  ** used calling dll     public function iscandevice_scan1(collections bbscan.template, byval scanpurpose bbscan.scanpurposes, byval scantimeout integer, region bbscan.scanregion) bbscan.scan_resultcodes   .   rc = testdemo.dobegincapture   .   .  ** called form internally when in exe mode ** , called calling dll via iscandevice_scan1 above public function dobegincapture() rc_resultcodes .   obj.dataeventenabled = true   dataevent = devent.begincapture .  . exit function   '**event processing**     public sub obj_dataevent(byval status long)  on error goto error_dataevent  select case dataevent     case devent.identify          dataevent = devent.none     case devent.beginverify corescan = obj.bir  ret = obj.endcapture() if ret = opossuccess             . else . end if              obj.dataeventenabled = true dataevent = devent.none      case devent.register              ret = obj.endcapture()          if ret = opossuccess .          else .          end if  obj.dataeventenabled = true           dataevent = devent.none  end select . . end sub  

so in summary calling dll displays msgbox , tries run printreport function without operating dll iscandevice_scan1 function completing.

it's not clear me / when return initial call _scan1. if, seems likely, return after invoking begincapture returning control caller before internal processing or events occur in callee, , program flow continues there.

if it's important processing in calling dll suspended until happens in called dll, must either keep locus of control in called dll, or wait in calling dll event signaled caller.


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -