Page 3 of 3 FirstFirst 123
Results 81 to 91 of 91

Thread: [VB6] - Module for working with multithreading.

  1. #81
    Addicted Member
    Join Date
    Dec 2021
    Posts
    144

    Re: [VB6] - Module for working with multithreading.

    Hello Trick,

    I tried the following two ways by removing the lib from references so that atl lib is accessible to vb client exe:


    1.Copied Project1.exe to atl project debug folder so that the vb client app can access atlsimpleobjdeno project dll and run Project1.exe.

    2.Copied atlsimpleobjdeno dll to vb client project folder so that the vb client app can access atlsimpleobjdeno project dll and run Project1.exe.

    But still I get the same invalid procedure call or argument error in both ways.


    Thanks
    Last edited by smkperu; Sep 6th, 2023 at 08:24 AM.

  2. #82

  3. #83
    Addicted Member
    Join Date
    Dec 2021
    Posts
    144

    Re: [VB6] - Module for working with multithreading.

    Quote Originally Posted by The trick View Post
    This problem is related to registering your Ax-component not module. Just register it properly.
    Hello trick,

    It does'nt matter whether I use

    Dim x As ATLSIMPLEOBJDENOLib.atlsimpleobjforvb or Dim x As Object in the simplevbatlclient standard exe project already attached

    If I comment

    Set x = CreateActiveXObjectInNewThread2("ATLSIMPLEOBJDENOLib.atlsimpleobjforvb", , asyncid)

    and use

    Set x = New atlsimpleobjforvb

    the simplevbatlclient project works fine .

    This implies that the atl component is registered properly in the already attached atlsimpleobjdeno atl project.

    What I observed was that CLSIDFromProgID returns < 0 making Err.Raise 5 being called in modMultiThreading2.bas in CreateActiveXObjectInNewThread2 function

    Code:
    ' // Create new ActiveX object in the new thread by ProgID
    Public Function CreateActiveXObjectInNewThread2( _
                    ByRef sProgID As String, _
                    Optional ByVal pIID As Long, _
                    Optional ByRef lAsynchId As Long) As IUnknown
        Dim tClsId  As tCurGUID
        
        If CLSIDFromProgID(StrPtr(sProgID), tClsId) < 0 Then
            Err.Raise 5
        End If
        
        Set CreateActiveXObjectInNewThread2 = CreateActiveXObjectInNewThread(VarPtr(tClsId), pIID, lAsynchId)
        
    End Function
    I tried to compile simplevbatlclient in admin mode and also run the Project1.exe in admin mode but I get same error.

    thanks

  4. #84

  5. #85
    Addicted Member
    Join Date
    Dec 2021
    Posts
    144

    Re: [VB6] - Module for working with multithreading.

    Quote Originally Posted by The trick View Post
    This error related to the registration because OLE can't find your Ax-DLL ProgID entry in the registry. I've already wrote the solution please read carefully.
    Hello Trick,


    Thank you.I corrected the ProgID.

    I have used atl object atlsimpleobjforvb which was not supporting events.

    Can I pass Atl object which supports events and using WithEvents can I call in vb client in CreateActiveXObjectInNewThread2 and receive events like callback examples.

    I am asking this since all your examples have no mention of receiving events.

    Thanks

  6. #86

  7. #87
    Addicted Member
    Join Date
    Dec 2021
    Posts
    144

    Re: [VB6] - Module for working with multithreading.

    Quote Originally Posted by The trick View Post
    Events should work. This is the same principle like there.
    Hello Trick,

    In order to test receiving events of private class Class1 in new thread I did a standard exe application with form1 having single button command1 and Class1 as follows:


    form1 code
    Code:
    Dim WithEvents x As Class1
    Private thid As Long
    
    Private Sub Command1_Click()
        'Set x = New Class1 'works fine
         Set x = CreatePrivateObjectByNameInNewThread("Class1", , thid) ' gives run time err 13 type mishmatch
         x.classmem
    End Sub
    
    Private Sub Form_Load()
         modMultiThreading.Initialize
         modMultiThreading.EnablePrivateMarshaling True
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
    modMultiThreading.Uninitialize
    End Sub
    
    Private Sub x_abc()
    MsgBox "in abc evt" ' not called in new thread
    End Sub
    Class1 code

    Code:
    Event abc()
    Sub classmem()
    RaiseEvent abc
    End Sub


    When I run and click the command1 button on displayed form1 I get Run-time error '13'. Type mismatch instead of getting Class1 abc event called and application exits.


    Project attached.


    Thanks
    Attached Files Attached Files

  8. #88

  9. #89

  10. #90
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,618

    Re: [VB6] - Module for working with multithreading.

    The discussion that wandered onto other subjects were moved to a new thread, since they were essentially questions, not a discussion of the topic of this CodeBank submission.
    My usual boring signature: Nothing

  11. #91
    Addicted Member
    Join Date
    Dec 2021
    Posts
    144

    Re: [VB6] - Module for working with multithreading.

    Quote Originally Posted by The trick View Post
    Guys, stop hijacking this thread. If you have any troubles with the module in the original post please report here. If you have other questions related multithreading/multiprocessing create a separate thread.
    Hello Trick,

    I started a new thread at https://www.vbforums.com/showthread....=1#post5619017

    Thanks

Page 3 of 3 FirstFirst 123

Tags for this Thread

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