vb.net线程传参 C#线程传递参数的方式
vb.net 怎样操作带参数的多线程
public class threadclass
邵武ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:13518219792(备注:SSL证书合作)期待与您的合作!
{
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 如何传递类参数
线程结束后利用委托生成事件返回,线程应用包括传入和传出参数。
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线程传参 C#线程传递参数的方式
当前URL:http://myzitong.com/article/higeog.html