What would be a good way to pass data back to Visual Basic?
No WAITFORSINGLEOBJECT because VB would have to wait which defeats the purpose of processing in the background.
The code below works great passing information from VB to PB and processing everything in the background so the VB program is always responsive.
Post #10 below is a tested working example of using threading with critical section protection
No WAITFORSINGLEOBJECT because VB would have to wait which defeats the purpose of processing in the background.
The code below works great passing information from VB to PB and processing everything in the background so the VB program is always responsive.
Code:
#COMPILE DLL "background.dll" DECLARE SUB BACKGROUND LIB "background.dll" (s$) GLOBAL gs AS STRING SUB Background(s AS STRING) EXPORT 'Do NOT SLEEP or WAITFORSINGLEOBJECT here or caller will wait LOCAL hThread, x AS DWORD gs=s THREAD CREATE BackGroundThread(x) TO hThread SLEEP 50 THREAD CLOSE hThread TO hThread END SUB THREAD FUNCTION BackGroundThread(BYVAL dummy AS DWORD) AS DWORD SLEEP 5000 'simulate processing ? gs + " done processing at " + TIME$ 'pass data back here? END FUNCTION
Comment