Results 1 to 22 of 22

Thread: VB6 Threading, using the small DirectCOM.dll-HelperLib

Threaded View

  1. #1

    Thread Starter
    Join Date
    Jun 2013

    VB6 Threading, using the small DirectCOM.dll-HelperLib

    Just for those who want to try a proven approach, which works reliably (and comparably simple)
    in spanning up STAs (Single-Threaded-Apartments) for over 10 years now (one can use his own
    VB6-compiled AX-Dlls which provide a Class-Instance that runs on said STA - no Assembler-Thunking,
    no TypeLibs and also no "special Dll-Exports" are needed - it's aside from a few API-calls just straight VB-Code).

    The Thread-Class-Instances in question are always created Regfree in this case (so,
    no Setup is needed - just ship your Thread-Dlls alongside DirectCOM.dll in a SubFolder
    of your App).

    The Demo here tries to show not only how to create the STA-threads with a Class-
    Instance in it, but also how to share Memory with the Applications Main-Thread
    (which is the fastest way of cross-thread-communication).

    The implementation of the Main-App is using a separate (Private) Wrapper-Class
    for handling the "Remote-Thread" (offering Properties to wrap the shared Memory-area,
    and such a Class will also automatically close the thread it wraps, in case it is itself terminated).

    That allows for cleaner Code in the "Thread-consuming-instance" (in our case the Apps fMain-Form).

    The Code for the ThreadLib.dll on the other hand - (this is the AX-Dll which provides a Public
    cThread-Class, which will finally run on its own threaded Apartment) - is contained in the
    \Bin\... SubFolder of the Zip.

    Just leave this Bin-SubFolder as it is, when you run the Main-Apps *.vbp File.

    Here's the Code for the Demo:

    And here is a ScreenShot (the colored Forms are created inside the 4 Threads - and perform
    an endless loop, to show some kind of "Plasma-Effect" - just to put the threads under stress a bit).

    Have fun (and just ask when you have any questions - though I tried to comment the Demo well enough, I hope).

    Last edited by Schmidt; May 22nd, 2015 at 04:27 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width