Thread in VB NET 2005

Tháng Chín 15, 2008 at 4:43 sáng Để lại phản hồi

Imports System.Threading
Public Class Form1

Dim tCounter As New Thread(AddressOf RunCounter)

Private Sub RunCounter()
Dim Counter As Integer

Do
setlabel(Counter & “/” & 10000)
Counter += 1
Loop While Counter < 10000
End Sub

Public Delegate Sub setlabeldelegate(ByVal text As String)
Private Sub setlabel(ByVal text As String)

If InvokeRequired Then
Invoke(New setlabeldelegate(AddressOf set_label), New Object() {text})
End If
set_label(text)

End Sub
Private Sub set_label(ByVal text As String)
Label1.Text = text
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If tCounter.IsAlive = False Then

tCounter.Start()

End If
End Sub

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
tCounter.Abort()
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
End Class

Entry filed under: VB.NET. Tags: .

Add Rows Number to DataGridView DataGridView Export to XLS File

Gửi phản hồi

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Thay đổi )

Twitter picture

You are commenting using your Twitter account. Log Out / Thay đổi )

Facebook photo

You are commenting using your Facebook account. Log Out / Thay đổi )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


 

Tháng Chín 2008
T2 T3 T4 T5 T6 T7 CN
« Tháng 8   Tháng 10 »
1234567
891011121314
15161718192021
22232425262728
2930  

Follow

Get every new post delivered to your Inbox.