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

Thread: VB Multithread Library (Generic Multithreading)

  1. #81
    Addicted Member
    Join Date
    Jun 2017
    Posts
    236

    Re: VB Multithread Library (Generic Multithreader)

    thank you , successful!!

  2. #82
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    678

    Re: VB Multithread Library (Generic Multithreader)

    hi Krool:
    Code:
     For i = 1 To 10
            Set mthread(i) = New Thread
    
            If InIDE() = True Then
                'MsgBox "In the IDE the threads are synchronous to the main thread." & vbLf & "DebugMode is set to True. (determined by the InIDE() function)", vbInformation + vbOKOnly
                mthread(i).DebugMode = True '
    
            End If
           mthread(i).Create Me, "TD" + CStr(i)
            Next
    Code:
    Private Sub IThread_BackgroundProcedure(ByVal Key As String, _
                                            ByVal StatusCallback As VBMThread11.IThreadStatusCallback, _
                                            ByVal Data As VBMThread11.ThreadData)
    
        Dim i As Integer, IsDebugMode As Boolean
    
        IsDebugMode = Data.DebugMode
    
        
        For i = 1 To 10
            StatusCallback.Raise (Mid(Key, 3) - 1) * 10 + i
    
            sleep 100
            
            If IsDebugMode = True Then DoEvents
        Next
    
     
    
    End Sub
    if i used 10 threads,download 100 (10×10) pics .when i make exe and run.
    The program is stuck and can not be moved using the mouse untile the 10 threads complete.

    if i change sleep 100 to doevents. can not useful. can have good ideas?
    Attached Images Attached Images  
    Last edited by xxdoc123; Aug 6th, 2017 at 02:59 AM.

  3. #83

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: VB Multithread Library (Generic Multithreader)

    @ xxdoc123, you need to place your download code into BackgroundProcedure and not in StatusCallback.
    All code should be in BackgroundProcedure. The StatusCallback is only a bridge to interact with the VB main thread, e.g. updating a ProgressBar etc.

  4. #84
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    678

    Re: VB Multithread Library (Generic Multithreader)

    Quote Originally Posted by Krool View Post
    @ xxdoc123, you need to place your download code into BackgroundProcedure and not in StatusCallback.
    All code should be in BackgroundProcedure. The StatusCallback is only a bridge to interact with the VB main thread, e.g. updating a ProgressBar etc.
    now i change the code what you say. but can used in ide,not run if make to exe. can you have a litter time to look my code?

    thanks.i am newbie,have poor knowledge about multithread.
    Attached Files Attached Files

  5. #85

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: VB Multithread Library (Generic Multithreader)

    @ xxdoc123, the problem lies in the fact that you use 'App.Path' within the BackgroundProcedure. You should store the save the path string within Form_Load and store it in a string which you then use within your GetData function that is called within BackgroundProcedure.

  6. #86
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    678

    Re: VB Multithread Library (Generic Multithreader)

    Quote Originally Posted by Krool View Post
    @ xxdoc123, the problem lies in the fact that you use 'App.Path' within the BackgroundProcedure. You should store the save the path string within Form_Load and store it in a string which you then use within your GetData function that is called within BackgroundProcedure.
    yes,i have change the app.path,but if i make to exe can not run.msgbox project error...if run in vb ide will be ok..my system is win7. 32. thanks. can you fixed ?put a project demo to me ?

  7. #87
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    678

    Re: VB Multithread Library (Generic Multithreader)

    i know,can not used cls。

  8. #88

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: VB Multithread Library (Generic Multithreader)

    I have got it to work.

    What you Need to do is as following:

    form-Level declarations:
    Code:
    Private AppPath As String, http As clshttp
    
    Implements IThread '
    During Form_Load:
    Code:
    Private Sub Form_Load()
    
    AppPath = App.Path
    Set http = New clshttp
    New GetData function:
    Code:
    Public Function GetData(temp As Integer) As Boolean '
        ' Sleep 200
        TestStr = "Test" + CStr(temp)
    
        'Dim http As clshttp
        'Set http = New clshttp
    
        If http.Download("http://www.vbforums.com/images/misc/logo.gif", AppPath & "\test\" & TestStr & ".gif") = True Then
        
            GetData = True
    
        End If
    
        'Set http = Nothing
    
    End Function

  9. #89
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    678

    Re: VB Multithread Library (Generic Multithreader)

    yes.your are right.now work ok.thanks

  10. #90

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: VB Multithread Library (Generic Multithreader)

    @ xxdoc123, one more thing.
    You use the .Cancel method somewhere, in order to be meaningful you need to add the following within in For..Loop in the BackgroundProcedure.
    Code:
    If Data.CancellationPending = True Then
        Data.Canceled = True
        Exit For
    End If

  11. #91
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    678

    Re: VB Multithread Library (Generic Multithreader)

    Quote Originally Posted by Krool View Post
    @ xxdoc123, one more thing.
    You use the .Cancel method somewhere, in order to be meaningful you need to add the following within in For..Loop in the BackgroundProcedure.
    Code:
    If Data.CancellationPending = True Then
        Data.Canceled = True
        Exit For
    End If
    thanks ,the project is my test. I just want to test it stability.the program works fine,Thank you for your work
    Last edited by xxdoc123; Aug 8th, 2017 at 12:03 AM.

  12. #92

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: VB Multithread Library (Generic Multithreader)

    This is just a question put in the room. Out of curiosity!

    The VBMThread11.DLL will just work fine in 32-bit VBA office. Whether .DebugMode is True or False.

    However, by certain registry hacks (https://techtalk.gfi.com/32bit-objec...t-environment/) it is possible to reference a 32-bit COM dll in 64-bit environment. (e.g. 64-bit VBA office)
    So in 64-bit VBA office the referencing works. But the threading does only work when using .DebugMode = True. (single-threaded)
    When changing .DebugMode = False (true multi-threading) nothing happens. I mean really nothing. Not even a crash happens. The only thing happens is that the active UserForm becomes inactive, but the BackgroundProcedure in IThread never got called.

    I don't know if anybody can give me an answer to this. Just wanted to put this out, as said, out of curiosity..

  13. #93

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: VB Multithread Library (Generic Multithreader)

    I guess I have the answer to my question.

    It seems the registry tweak just allows to interoperability between 64bit and 32bit in a "interface wise" mean.
    So 32bit can still not be "hosted" in 64bit environment. And by hosted is kind of an ActiveX control or in this sense a "call" from a 32bit thread to a 64bit environment.
    The reason why it works with .DebugMode = True is because as the main 64bit thread will run its own call.

    So the benefits of that DllSurrogate registry tweaks are limited..

  14. #94
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,155

    Re: VB Multithread Library (Generic Multithreader)

    These registry "hacks" seem to register the x86 component as a COM+ application which as a consequence makes you library an out-of-process component for the x64 client.

    cheers,
    </wqw>

  15. #95
    New Member
    Join Date
    Feb 2016
    Posts
    4

    Re: VB Multithread Library (Generic Multithreader)

    Is any help from Microsoft Website?
    https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx

  16. #96

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: VB Multithread Library (Generic Multithreader)

    Quote Originally Posted by wqweto View Post
    These registry "hacks" seem to register the x86 component as a COM+ application which as a consequence makes you library an out-of-process component for the x64 client.

    cheers,
    </wqw>
    "Out-of-process" is a perfect description for that case. Thanks

  17. #97

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: VB Multithread Library (Generic Multithreading)

    Included LinkSwitch /OPT:NOWIN98 on the VBCompiler which reduced the file size of the DLL from 48KB to 36KB

  18. #98
    Member
    Join Date
    Oct 2008
    Posts
    56

    Re: VB Multithread Library (Generic Multithreading)

    Hi for all
    I need to use multithreading. I did a test using the VBMThread11 DLL.
    I downloaded the xxdoc123 test program.
    I do not understand why I do not receive an indication of the end of the thread execution with the msgbox inserted for this.
    Furthermore, the sequence of thread execution does not seem to be as expected.
    Thanks
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by VBDevelopper; May 22nd, 2018 at 12:23 PM.

  19. #99

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: VB Multithread Library (Generic Multithreading)

    Quote Originally Posted by VBDevelopper View Post
    Hi for all
    I need to use multithreading. I did a test using the VBMThread11 DLL.
    I downloaded the xxdoc123 test program.
    I do not understand why I do not receive an indication of the end of the thread execution with the msgbox inserted for this.
    Furthermore, the sequence of thread execution does not seem to be as expected.
    Thanks
    You have a logic error, try instead of:
    Code:
    Private Sub IThread_Complete(ByVal Key As String, ByVal Data As VBMThread11.ThreadData)
    
        If Data.Canceled = False Then
            Debug.Print Mid(Key, 3) & "complete"
            Debug.Print Mid(Key, 3) & "mThreadid=" & mThread((Mid(Key, 3))).hThread
        Else
            MsgBox Mid(Key, 3) & "mThread have end", vbInformation + vbOKOnly
        End If
    
    End Sub
    the following:
    Code:
    Private Sub IThread_Complete(ByVal Key As String, ByVal Data As VBMThread11.ThreadData)
    If Data.Canceled = False Then
        If Data.DebugMode = True Then
            Debug.Print Mid(Key, 3) & "complete"
            Debug.Print Mid(Key, 3) & "mThreadid=" & mThread((Mid(Key, 3))).hThread
        Else
            MsgBox Mid(Key, 3) & "mThread have end", vbInformation + vbOKOnly
        End If
    End If
    End Sub

  20. #100
    Addicted Member
    Join Date
    May 2016
    Location
    China
    Posts
    197

    Re: VB Multithread Library (Generic Multithreading)

    The test was successful, but unfortunately can not be used for database queries: in the query did not complete the progress bar or not move.
    QQ: 289778005

  21. #101

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: VB Multithread Library (Generic Multithreading)

    Quote Originally Posted by ChenLin View Post
    The test was successful, but unfortunately can not be used for database queries: in the query did not complete the progress bar or not move.
    If you use directly on SQL server it might work.
    If you use on jet access db then not as async processing is not possible. The task are done in a queue one by one so even multithreading does not help.

    Edit: And for example when using ADO you can then execute a query in StatusCallback via the main project ADODB conn with the dbAsync option. But again, does not work on access db.
    Last edited by Krool; May 22nd, 2018 at 10:51 PM.

  22. #102
    Addicted Member
    Join Date
    May 2016
    Location
    China
    Posts
    197

    Re: VB Multithread Library (Generic Multithreading)

    Quote Originally Posted by Krool View Post
    If you use directly on SQL server it might work.
    If you use on jet access db then not as async processing is not possible. The task are done in a queue one by one so even multithreading does not help.

    Edit: And for example when using ADO you can then execute a query in StatusCallback via the main project ADODB conn with the dbAsync option. But again, does not work on access db.
    Code:
    Public Function ExecuteSQL(ByVal SqlStr As String, Optional ErrMsg As String) As ADODB.Recordset
    0   On Error GoTo ExectueSql_Error
        Dim Mycon As ADODB.Connection
        Dim rst As ADODB.Recordset
        Set Mycon = New ADODB.Connection
        Mycon.ConnectionString = ConnString
        Mycon.ConnectionTimeout = Val(lTmr) + 1
        Mycon.Open
        
        Dim stokens() As String
        On Error GoTo ExectueSql_Error
        stokens = Split(SqlStr)
        If InStr("INSERT,DELETE,UPDATE", UCase(stokens(0))) Then
            Mycon.Execute SqlStr
        Else
            Set rst = New ADODB.Recordset
            rst.CursorLocation = adUseClient
            'rst.Properties("Initial Fetch Size") = 50
            rst.Open Trim(SqlStr), Mycon, adOpenKeyset, adLockOptimistic ',adCmdText
            Set ExecuteSQL = rst
        End If
    ExectueSql_Exit:
        Set rst = Nothing
        Set Mycon = Nothing
        Exit Function
    ExectueSql_Error:
        If err.Number = -2147467259 Then '解决 Named Pipes 错误
            SaveRegistryKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo", strServerName, "DBMSSOCN," & strServerName
            ErrMsg = "连接数据库服务器 " & " 错误:" & vbCrLf & vbCrLf & err.Description
        Else
            ErrMsg = err.Description
        End If
        'WriteErrLog ErrMsg
        Resume ExectueSql_Exit
    End Function
    I'm using this. May I have this, please?
    Yesterday's test was ADO data control, which has been tested.
    QQ: 289778005

  23. #103
    Member
    Join Date
    Oct 2008
    Posts
    56

    Re: VB Multithread Library (Generic Multithreading)

    Quote Originally Posted by Krool View Post
    You have a logic error, try instead of:
    Code:
    Private Sub IThread_Complete(ByVal Key As String, ByVal Data As VBMThread11.ThreadData)
    
        If Data.Canceled = False Then
            Debug.Print Mid(Key, 3) & "complete"
            Debug.Print Mid(Key, 3) & "mThreadid=" & mThread((Mid(Key, 3))).hThread
        Else
            MsgBox Mid(Key, 3) & "mThread have end", vbInformation + vbOKOnly
        End If
    
    End Sub
    the following:
    Code:
    Private Sub IThread_Complete(ByVal Key As String, ByVal Data As VBMThread11.ThreadData)
    If Data.Canceled = False Then
        If Data.DebugMode = True Then
            Debug.Print Mid(Key, 3) & "complete"
            Debug.Print Mid(Key, 3) & "mThreadid=" & mThread((Mid(Key, 3))).hThread
        Else
            MsgBox Mid(Key, 3) & "mThread have end", vbInformation + vbOKOnly
        End If
    End If
    End Sub
    With your suggestion the program works.
    you excuse my banality, but I did not understand some things.
    1)
    Because we need the timer to check if all the threads are finished.
    The IThread_Complete event could not be used for this.
    2)
    The IThread_BackgroundProcedure is a procedure is not an event? Quite right?
    3)
    Is IThread_Complete an event?
    It is not generated when the thread ends as the name would seem to say.
    4) The IThread_StatusCallback event is generated by the program. But is it always like this?
    The thread that is executed does not generate it?
    Thank

  24. #104

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: VB Multithread Library (Generic Multithreading)

    Quote Originally Posted by VBDevelopper View Post
    With your suggestion the program works.
    you excuse my banality, but I did not understand some things.
    1)
    Because we need the timer to check if all the threads are finished.
    The IThread_Complete event could not be used for this.
    2)
    The IThread_BackgroundProcedure is a procedure is not an event? Quite right?
    3)
    Is IThread_Complete an event?
    It is not generated when the thread ends as the name would seem to say.
    4) The IThread_StatusCallback event is generated by the program. But is it always like this?
    The thread that is executed does not generate it?
    Thank
    IThread is an interface definition and not event driven. It's called by interface methods.

    Interface method when a thread's background procedure is called.
    Code:
    Public Sub BackgroundProcedure(ByVal Key As String, ByVal StatusCallback As IThreadStatusCallback, ByVal Data As ThreadData)
    
    StatusCallback.Raise 1&, "Test" ' StatusCallback method called.
    
    End Sub
    Interface method when a thread's background procedure has been completed or canceled.
    The Thread is already terminated (hThread = 0) when this method is called.
    Code:
    Public Sub Complete(ByVal Key As String, ByVal Data As ThreadData)
    
    End Sub
    Interface method when a thread requests an synchronous status callback. The background thread will be suspended, the method request is marshaled to the main thread.
    Code:
    Public Sub StatusCallback(ByVal Key As String, ByRef Argument1 As Variant, ByRef Argument2 As Variant)
    
    End Sub

  25. #105
    Member
    Join Date
    Oct 2008
    Posts
    56

    Re: VB Multithread Library (Generic Multithreading)

    Hi Krool.
    Thanks.
    Now it is a bit more clear.
    You have to excuse me, but I now approach this advanced programming.
    I still have a small question.
    Why is this thread called "(Multithreading generic)"?
    Are there any other types of multithread?

  26. #106

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: VB Multithread Library (Generic Multithreading)

    Quote Originally Posted by VBDevelopper View Post
    Hi Krool.
    Thanks.
    Now it is a bit more clear.
    You have to excuse me, but I now approach this advanced programming.
    I still have a small question.
    Why is this thread called "(Multithreading generic)"?
    Are there any other types of multithread?
    The official VB6 multithreading is a ActiveX EXE. Like a COM DLL it must be registered.
    However, "your code" must be placed inside that ActiveX EXE. So for each purpose or task you may need to change that ActiveX EXE or create another one.

    This generic DLL allows to place "your code" inside your "own app". So for whatever task or purpose you can change "your app".
    This is meant by "generic". The DLL remains always unchanged.

  27. #107
    Member
    Join Date
    Oct 2008
    Posts
    56

    Re: VB Multithread Library (Generic Multithreading)

    but if there are the activeX because one needs to use other paths?
    Last edited by VBDevelopper; May 25th, 2018 at 04:51 AM.

  28. #108
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: VB Multithread Library (Generic Multithreading)

    Quote Originally Posted by VBDevelopper View Post
    but if there are the activeX because one needs to use other paths?
    FYI ActiveX EXE's can't be run without either being "installed" with administrator rights, or run the first time with administrator rights, where it registers it's interfaces.
    Krool's DLL however can be used SxS, without the need for admin rights.

  29. #109
    Member
    Join Date
    Oct 2008
    Posts
    56

    Re: VB Multithread Library (Generic Multithreading)

    OK. Thanks

  30. #110

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: VB Multithread Library (Generic Multithreading)

    Quote Originally Posted by ChenLin View Post
    Code:
    Public Function ExecuteSQL(ByVal SqlStr As String, Optional ErrMsg As String) As ADODB.Recordset
    0   On Error GoTo ExectueSql_Error
        Dim Mycon As ADODB.Connection
        Dim rst As ADODB.Recordset
        Set Mycon = New ADODB.Connection
        Mycon.ConnectionString = ConnString
        Mycon.ConnectionTimeout = Val(lTmr) + 1
        Mycon.Open
        
        Dim stokens() As String
        On Error GoTo ExectueSql_Error
        stokens = Split(SqlStr)
        If InStr("INSERT,DELETE,UPDATE", UCase(stokens(0))) Then
            Mycon.Execute SqlStr
        Else
            Set rst = New ADODB.Recordset
            rst.CursorLocation = adUseClient
            'rst.Properties("Initial Fetch Size") = 50
            rst.Open Trim(SqlStr), Mycon, adOpenKeyset, adLockOptimistic ',adCmdText
            Set ExecuteSQL = rst
        End If
    ExectueSql_Exit:
        Set rst = Nothing
        Set Mycon = Nothing
        Exit Function
    ExectueSql_Error:
        If err.Number = -2147467259 Then '解决 Named Pipes 错误
            SaveRegistryKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo", strServerName, "DBMSSOCN," & strServerName
            ErrMsg = "连接数据库服务器 " & " 错误:" & vbCrLf & vbCrLf & err.Description
        Else
            ErrMsg = err.Description
        End If
        'WriteErrLog ErrMsg
        Resume ExectueSql_Exit
    End Function
    I'm using this. May I have this, please?
    Yesterday's test was ADO data control, which has been tested.
    May have what?

    The best is you create the ADODB.Connection and ADODB.Recordset within the IThread_BackgroundProcedure from scratch (Early-bound works from main thread references) and then just execute or do your queries form there and communicate your results via StatusCallback. No dbAsyncExecute needed.
    However, as said when using access mdb files it's not working since file locking. On SQL server it should work just well.

  31. #111
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,155

    Re: VB Multithread Library (Generic Multithreading)

    JFYI, when sample project VBMThread11Demo.zip is compiled to P-Code all samples seem to freeze which is very weird.

    The multi-threader is left natively compiled DLL, only the IThread interface implementation is P-Code compiled and still the runtime doesn't like this scenario.

    cheers,
    </wqw>

  32. #112

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: VB Multithread Library (Generic Multithreading)

    Quote Originally Posted by wqweto View Post
    JFYI, when sample project VBMThread11Demo.zip is compiled to P-Code all samples seem to freeze which is very weird.

    The multi-threader is left natively compiled DLL, only the IThread interface implementation is P-Code compiled and still the runtime doesn't like this scenario.
    Added a note in thread's first post that P-Code will fail. So maybe it's more noticed for new users.

  33. #113
    Addicted Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    234

    Re: VB Multithread Library (Generic Multithreader)

    Quote Originally Posted by Krool View Post
    Here is a solution to use the VBMThread11.DLL Registration-Free. (Side-by-side)
    Keep in mind that this technology needs at minimum Windows XP SP2 or Windows Server 2003.

    Big thanks goes to 'the trick' for the solution with "comInterfaceExternalProxyStub" in the manifest.

    Tutorial:
    The "Development" machine needs to register VBMThread11.DLL as usual and use the components for e.g. in a Std-EXE project.
    The source project needs to include the Side-by-side resources. (see below)
    Then on the "End user" machine you only need the VBMThread11.DLL and the .exe (Std-EXE project) on the same folder.
    It will work then without any registration.

    The source code of "VBMThread11SideBySide.res" is:

    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
       <file name="VBMThread11.DLL">
          <typelib tlbid="{1A02D9E1-9609-40B3-8AFE-727D8A144707}" version="1.0" flags="" helpdir="" />
          <comClass clsid="{AAE10FA6-5E20-4FA7-9649-678DC3971353}" tlbid="{1A02D9E1-9609-40B3-8AFE-727D8A144707}" threadingModel="Apartment" progid="VBMThread11.Thread" description="" />
       </file>
       <comInterfaceExternalProxyStub
          name = "_Thread"
          iid="{71154E34-A914-4E30-A4BA-5CE94A6D9C46}"
          proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"
          baseInterface="{00000000-0000-0000-C000-000000000046}"
          tlbid="{1A02D9E1-9609-40B3-8AFE-727D8A144707}">
       </comInterfaceExternalProxyStub>
       <comInterfaceExternalProxyStub
          name = "__Thread"
          iid="{403717A2-9E4E-4FEC-B77A-62DC68B9C294}"
          proxyStubClsid32="{00020420-0000-0000-C000-000000000046}"
          baseInterface="{00000000-0000-0000-C000-000000000046}"
          tlbid="{1A02D9E1-9609-40B3-8AFE-727D8A144707}">
       </comInterfaceExternalProxyStub>
       <comInterfaceExternalProxyStub
          name = "_ThreadData"
          iid="{55A8AC17-7DB5-468D-93BD-86E8B97C53A5}"
          proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"
          baseInterface="{00000000-0000-0000-C000-000000000046}"
          tlbid="{1A02D9E1-9609-40B3-8AFE-727D8A144707}">
       </comInterfaceExternalProxyStub>
       <comInterfaceExternalProxyStub
          name = "_IThread"
          iid="{68F61D7E-21CD-41E6-AFEC-C3820C6743D5}"
          proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"
          baseInterface="{00000000-0000-0000-C000-000000000046}"
          tlbid="{1A02D9E1-9609-40B3-8AFE-727D8A144707}">
       </comInterfaceExternalProxyStub>
       <comInterfaceExternalProxyStub
          name = "_IThreadStatusCallback"
          iid="{09256C4A-7A89-40F6-BBEE-3D5445942C4A}"
          proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"
          baseInterface="{00000000-0000-0000-C000-000000000046}"
          tlbid="{1A02D9E1-9609-40B3-8AFE-727D8A144707}">
       </comInterfaceExternalProxyStub>
    </assembly>
    In the attachment I have added the same as a compiled resource.
    Dear Krool,

    First of all, I wish to inform that this is the first time I have found the need to go in for MultiThreading. So, while searching in the net, I landed first on Olaf's solution - at https://www.vbforums.com/showthread....-(simple-Demo) - which led to https://www.vbforums.com/showthread....rot-Rendering) - which provides a DLL route also to achieve MultiThreading. I have not explored these solutions yet.

    Point A)
    Coming to your solution, kindly educate/clarify on the following. I am asking these for clear understanding on the fundamental things, during development and deployment.
    --
    1. Registering VBMThread11.DLL alone is enough as far as I keep working on my "Development" machine. Right?

    2. My source project needs to include the Side-by-side resource ONLY in the case of the ""End user" machine. Right? And this inclusion is required so that registration of the DLL can be avoided in user-end. Right? In other words, if DLL registration is done in user-end also, then inclusion of your side-by-side resource ("VBMThread11SideBySide.res") in my project is not required. Right?

    3. Even in my "Development" system, if I include your side-by-side resource ("VBMThread11SideBySide.res") in my project, then registering of the DLL is not necessary in my "Development" system too. Right?
    --

    Though I will be eventually including your side-by-side resource in my project so that registration is avoided at user-end, still for my understanding purpose, I request you to educate me on the above 3 questions, so that I get a clear understanding of the fundamental matters.

    Point B)
    Coming to the task of including your side-by-side resource in my source project, how exactly should I do that? I am asking this because I already have an existing .res file in my project and VB6 allows to add only one resource file at any time.

    Further, when I open my project's existing .res file in Notepad, I find that its top few lines are almost exactly the same as the contents## I find in the 'Resources.res' file in the "..\..\VBMThread11Demo\Resources" directory of yours. Thereafter, the details in my .res file pertain to the other files (quite many) I have added to it later on, via the VB6 IDE.

    The top few lines of contents##, as far as I have understood over the years, pertain to the 'Visual Styles' aspect. So, what I need to add now to my project are only the contents of your "VBMThread11SideBySide.res" file. Right? But, how do I add the contents of your "VBMThread11SideBySide.res" file into my already existing .res file? What is the correct procedure so that the added contents do what they are supposed to do. Kindly please let me know.

    I used "Add Custom Resource" in the 'VB Resource editor' to add "VBMThread11SideBySide.res" to my .res file. After that, when my .res file is viewed in Notepad, I see that the contents of "VBMThread11SideBySide.res" gets added at the very end of my .res file. Is this correct? Will this be enough for safe deployment of my app at user-end? If not, kindly let me know the correct procedure.

    I also read some years back that the .res file size should be a multiple of 4096 or something like ,that. I don't know in relation to what I read that info. Should that be the case for my .res file too after adding the contents of "VBMThread11SideBySide.res" to it. If so, how to ensure that correct size for my .res? Kindly educate.

    Point C)
    Well, apart from the above procedure which I request you to let me know, if I use Olaf's "DirectCom.DLL' method, then that will also automatically register your "VBMThread11.DLL" in end-user machine. Right? If so, no need to add the contents of "VBMThread11SideBySide.res" to my .res file. Right?

    I take this opportunity to once again thank you for all your fabulous free contributions so far. God Bless you! God Bless all!

    Kind Regards.

    (##)
    --
    ÿÿ ÿÿ ˜ ÿÿ ÿÿ 0 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <dependency>
    <dependentAssembly>
    <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" language="*" processorArchitecture="*" publicKeyToken="6595b64144ccf1df"/>
    </dependentAssembly>
    </dependency>
    </assembly>
    --

    Edit 1:
    - While using "Add Custom Resource", I did move the added content to "#24" and gave '2' for ID since the earlier manifest contents (for Visual Styles) I have under "#24" has the ID '1' already.
    - While waiting to see the perfectly right procedure from you, I did try ResourceHacker; added the contents of "VBMThread11SideBySide.res" below the already existing contents of ID 1 under "#24"; saved into a new .res file (say aaa.res); deleted the existing .res in my project; tried to add aaa.res to my project but it did not get added. Probably the DWord alignment was not present.
    - Will try the code given by LaVolpe (at https://www.vbforums.com/showthread....=1#post5485439) soon.

    Edit 2:
    Tried the code given by LaVolpe. Seems to do the same thing as I did manually using "Add Custom Resource" except that the combined .res file got by using LaVolpe's code was few bytes lesser than the updated .res file I got after I manually modified it using "Add Custom Resource".
    Last edited by softv; Nov 16th, 2023 at 12:42 PM.

Page 3 of 3 FirstFirst 123

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