如何给线程中的变量赋值
如何给线程中的变量赋值
[解决办法]
不明白什么意思,是这样的吗?
Public Class Form1
Private ThreadDate As Date
Private MyThread As System.Threading.Thread
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Console.WriteLine( "线程退出! ")
MyThread.Abort()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MyThread = New Threading.Thread(AddressOf GetTime)
MyThread.Start()
Console.WriteLine( "线程启动! ")
End Sub
Private Sub GetTime()
Do
ThreadDate = Now
Console.WriteLine(ThreadDate.ToString)
Threading.Thread.Sleep(1000)
Loop
End Sub
End Class
[解决办法]
线程运行类中函数,其中也可以操作类的字段
给类的字段赋值即可
[解决办法]
http://www.msdn.net/library/chs/default.asp?url=/library/chs/vbcn7/html/vaconparametersreturnvaluesforfreethreadedprocedures.asp