-
Oct 22nd, 2020, 06:28 AM
#1
Thread Starter
New Member
Synchronous processing?
Hi All,
New to this forum but so pleased to have found it. I'm more than twice the age of VB and detest VB.Net... so maybe I'm just a grumpy ol' coder.
Anyway I've never really got my head around Synchronous Processing in VB6 and was hoping someone might be kind enough to point me in the right direction foe any code samples or documentation on the subject.
Maybe I'm on the wrong track altogether but I believe I could possibly achieve this by using an ActiveX EXE from my VB app? I'm really only looking at a very simple setup where say the main program (A) kicks off program (B) to do some lengthy time consuming task, whilst program (A) continues to do other things. When program (B) completes its task it somehow informs program (A) that it's finished, but that final event shouldn't interrupt or stop program (A) if it's still in the middle of doing something. If that makes sense?
Is this something that could be done with a standard VB6 app and an ActiveX EXE or DLL maybe?
Any help/advice would be most appreciated
Thank you
-
Oct 22nd, 2020, 08:35 AM
#2
Fanatic Member
Re: Synchronous processing?
In your above request for help, you already have your answer.
Create two apps (A and B). In App A write some code to receive a notice from AppB. This could be as simple as putting a hidden textbox on AppA.
When AppB is done, have it make a XProcess call to the AppA textbox (your notification code would go in the textbox change event) and you have your notification. There are a number of other ways to do this.
Search the forum for XProcess or Call Another Process.
Last edited by vb6forever; Oct 22nd, 2020 at 08:38 AM.
-
Oct 22nd, 2020, 10:18 AM
#3
Thread Starter
New Member
Re: Synchronous processing?
Thanks for the reply. I didn't really want two separate apps. If I did then yes I could easily achieve what I want using the Winsock control but having two apps presents its own problems.
-
Oct 22nd, 2020, 10:56 AM
#4
Re: Synchronous processing?
I'm not sure there is any way to have a stable background worker thread in VB6 without using a separate DLL.
Either go with an ActiveX EXE or a worker process program. There are ways to do both of these compiled as a single EXE.
-
Oct 22nd, 2020, 12:28 PM
#5
Re: Synchronous processing?
Originally Posted by dilettante
Either go with an ActiveX EXE or a worker process program. There are ways to do both of these compiled as a single EXE.
I would go with multi-process *Standard* EXE the way chrome or AnyDesk are implemented.
For instance AnyDesk spawn multiple processes of the single portable application with parameters like AnyDesk.exe --backend or AnyDesk.exe --service or AnyDesk.exe --control.
Each of these can register file monikers in ROT to be available to service out-of-process requests asynchronously in the same manner ActiveX EXEs register their class factories. The name of the registered moniker can include a generated GUID (or parent process ID) which can be received as a command line parameter too.
This is firefox command line:
Code:
"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -contentproc
--channel="2768.0.206578502\1378895978"
-parentBuildID 20181030165643
-greomni "C:\Program Files (x86)\Mozilla Firefox\omni.ja"
-appomni "C:\Program Files (x86)\Mozilla Firefox\browser\omni.ja"
-appdir "C:\Program Files (x86)\Mozilla Firefox\browser"
- "C:\Users\xxx\AppData\LocalLow\Mozilla\Temp-{98bf7eaf-7cbf-46a5-8d27-bbea0a9efccb}"
2768 "\\.\pipe\gecko-crash-server-pipe.2768" 944 gpu
Added bonus is that whenever the worker process crashes it does not bring down the whole application and also the worker process can be spawned elevated or under NT AUTHORITY\SYSTEM security credentials for instance.
cheers,
</wqw>
Last edited by wqweto; Oct 23rd, 2020 at 06:17 AM.
-
Oct 23rd, 2020, 05:56 AM
#6
Thread Starter
New Member
Re: Synchronous processing?
Thanks for all the replies. I found the following website really useful and have now cobbled together an ActiveX.exe to do what I want.
https://www.tutorialsweb.com/activex/activex.htm
-
Oct 23rd, 2020, 05:59 AM
#7
Re: Synchronous processing?
Originally Posted by OnCourse
These have troubles when run by non-admin users on Win10. Test yourself if working ok once registered on the machine by an admin.
cheers,
</wqw>
-
Oct 23rd, 2020, 06:07 AM
#8
Re: Synchronous processing?
I felt the same way but bit the bullet and switched to VB .NET and I'm glad I did. Here is a sample background worker that someone on this forum put together. It runs right out of the box. Just for grins you might download Visual Studio and run it. You might be pleasantly surprised.
http://www.vbforums.com/showthread.p...ckgroundWorker
Please remember next time...elections matter!
-
Oct 23rd, 2020, 07:05 AM
#9
Re: Synchronous processing?
I think you meant Asynchronous. Here there is an approach using processes. (I didn't use or tested it).
-
Oct 23rd, 2020, 08:11 AM
#10
Re: Synchronous processing?
No, I think he meant synchronous as in blocking. He wants to write QBasic in VB6.
-
Oct 23rd, 2020, 08:27 AM
#11
Re: Synchronous processing?
Originally Posted by dilettante
No, I think he meant synchronous as in blocking. He wants to write QBasic in VB6.
For synchronous he does not need to launch anything external, just to write VB code.
Originally Posted by OnCourse
the main program (A) kicks off program (B) to do some lengthy time consuming task, whilst program (A) continues to do other things. When program (B) completes its task it somehow informs program (A)
That looks asynchronous to me.
-
Oct 23rd, 2020, 09:25 AM
#12
Re: Synchronous processing?
I'm pretty sure the question is seeking ways to write blocking code without tying up the UI thread.
-
Oct 23rd, 2020, 10:25 AM
#13
Re: Synchronous processing?
Originally Posted by dilettante
I'm pretty sure the question is seeking ways to write blocking code without tying up the UI thread.
Originally Posted by OnCourse
whilst program (A) continues to do other things.
Then the only "other things" is to wait for the other program to finish.
There are several ways to do that, for example this one.
-
Oct 23rd, 2020, 11:04 AM
#14
Re: Synchronous processing?
wqweto suggested the good approach. Just i want to add you can use an OBJREF moniker as well.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|