网站建设资讯

NEWS

网站建设资讯

vb.net线程传参,c++线程传参

vb.net 线程 如何动态 address of 过程,即 "过程" 是可以用户动态传送的。

过程名是不可能作为参数使用的,想必你需要调用的过程是有限的,那么可以用一个变量来确定:

成都创新互联公司-专业网站定制、快速模板网站建设、高性价比芜湖网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式芜湖网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖芜湖地区。费用合理售后完善,十载实体公司更值得信赖。

sub 过程名(p as integer)

Dim i As Threading.Thread

select case p

case 1

i = New Threading.Thread(AddressOf 过程1)

case 2

i = New Threading.Thread(AddressOf 过程2)

.........................

..........................

end select

i.start()

end sub

vb.net 如何传递类参数

线程结束后利用委托生成事件返回,线程应用包括传入和传出参数。

Public Delegate Sub ThreadCallback(value As ThreadResult)

Public Class Form1

Private WithEvents _th_1 As Thread_1

Protected Overrides Sub OnLoad(e As System.EventArgs)

Dim value As ThreadObject

value.Index = 1

Me._th_1 = New Thread_1(Me)

Me._th_1.Run(value)

MyBase.OnLoad(e)

End Sub

Private Sub Thread_1_End(sender As Object, e As ThreadEventArgs) Handles _th_1.ThreadEnd

Me.TextBox1.Text = e.Result.Text

End Sub

End Class

Public Class Thread_1

Public Event ThreadEnd(sender As Object, e As ThreadEventArgs)

Private _control As Control

Sub New(control As Control)

Me._control = control

End Sub

Public Sub Run(value As Object)

Dim th As New Threading.Thread(AddressOf ThreadProc)

th.Start(value)

End Sub

Private Sub ThreadProc(obj As Object)

Dim value As ThreadObject = CType(obj, ThreadObject)

Dim result As ThreadResult = Nothing

If value.Index = 1 Then result.Text = "测试"

Dim callback As New ThreadCallback(AddressOf ThreadInvoke)

_control.Invoke(callback, result)

End Sub

Private Sub ThreadInvoke(value As ThreadResult)

RaiseEvent ThreadEnd(Me, New ThreadEventArgs(value))

End Sub

End Class

Public Structure ThreadObject

Public Index As Integer

'Public Rect As Rectangle

End Structure

Public Structure ThreadResult

Public Text As String

'Public Rect As Rectangle

End Structure

Public Class ThreadEventArgs

Inherits System.EventArgs

Private _result As ThreadResult

Public ReadOnly Property Result As ThreadResult

Get

Return _result

End Get

End Property

Sub New(value As ThreadResult)

Me._result = value

End Sub

End Class

vb.net 怎样操作带参数的多线程

public class threadclass

{

public int a;

public void threadmethod()

{

//use a;

}

}

...

threadclass tc = new ....

tc.a = 10;

Thread t = new ThreadStart(tc.threadmethod);

t.Start

VB.NET线程内调用带参数的方法异常

报错信息是什么?截图一下。

---------补充----------------

你这报错与线程应该关系不大吧,是调用COM不熟悉造成的,在项目属性里面有些相关配置你研究研究。

Vb.net 怎样操作有参数的多线程而且还是循环的。

Sub Main()

Dim thr As New Thread(AddressOf 循环)

thr.Start("a")

End Sub

Sub 循环(a() As String)

'这里随你干什么循环也行

For Each i As String In a

MsgBox(i)

Next

End Sub

看懂了吧 参数只能有一个 也可以不是数组,在a() As String的a后面去掉括号就行


新闻名称:vb.net线程传参,c++线程传参
本文网址:http://njwzjz.com/article/dsidhop.html