How to pass multiple parameters in thread in VB

前端 未结 8 1422
面向向阳花
面向向阳花 2020-12-30 05:31

I\'m looking to pass two or more parameters to a thread in VB 2008.

The following method (modified) works fine without parameters, and my status bar gets updated ver

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-30 05:36

    In addition to what Dario stated about the Delegates you could execute a delegate with several parameters:

    Predefine your delegate:

    Private Delegate Sub TestThreadDelegate(ByRef goodList As List(Of String), ByVal coolvalue As Integer)
    

    Get a handle to the delegate, create parameters in an array, DynamicInvoke on the Delegate:

    Dim tester As TestThreadDelegate = AddressOf Me.testthread
    Dim params(1) As Object
    params(0) = New List(Of String)
    params(1) = 0
    
    tester.DynamicInvoke(params)
    

提交回复
热议问题