How to pass multiple parameters in thread in VB

前端 未结 8 1433
面向向阳花
面向向阳花 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:54

    Something like this (I'm not a VB programmer)

    Public Class MyParameters
        public Name As String
        public Number As Integer
    End Class
    
    
    
    newThread as thread = new Thread( AddressOf DoWork)
    Dim parameters As New MyParameters
    parameters.Name = "Arne"
    newThread.Start(parameters);
    
    public shared sub DoWork(byval data as object)
    {
        dim parameters = CType(data, Parameters)
    
    }
    

提交回复
热议问题