'//定義一個Thread
Dim FTPThread As Thread = Nothing
'//多執行緒所要執行的程式
Private Sub conFTP()
.......
End Sub
Private Sub Form_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
'//執行緒一(執行FTP)
Me.FTPThread = New Thread( _
New Threading.ThreadStart(AddressOf Me.conFTP))
Me.FTPThread.Start()
'//執行緒二(控制lab讀取中的進度顯示)
Dim p As New Show_prog(Label2, Timer2)
p.showProg()
End Sub
'//控制lab讀取中的進度顯示
Public Class Show_prog
Dim v_ShowMsg As String = ""
Dim c_lab As Label
Dim c_tim As Timer
Public Sub New(ByVal lab As Label, ByVal tim As Timer)
c_lab = lab
c_tim = tim
End Sub
'''
''' 顯示
'''
Public Sub showProg()
c_lab.Text = v_ShowMsg
c_lab.Visible = True
c_tim.Interval = 300
c_tim.Enabled = True
'lab
c_lab.Location = New Point(70, 147)
AddHandler c_tim.Tick, AddressOf Timer_Tick
End Sub
Dim i As Integer = 0
Public Sub Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
If OBS1.v_bol_FTP = False Then '//是否讀取結束
c_lab.Visible = False
RemoveHandler c_tim.Tick, AddressOf Timer_Tick
Else
Select Case i
Case 0
v_ShowMsg = "讀取中."
Case 1
v_ShowMsg = "讀取中.."
Case 2
v_ShowMsg = "讀取中..."
Case 3
v_ShowMsg = "讀取中...."
Case 4
v_ShowMsg = "讀取中....."
Case 5
v_ShowMsg = "讀取中......"
Case 6
v_ShowMsg = "讀取中......."
Case 7
v_ShowMsg = "讀取中........"
Case 8
v_ShowMsg = "讀取中........."
Case 9
v_ShowMsg = "讀取中.........."
i = 0
End Select
i += 1
c_lab.Text = v_ShowMsg
c_lab.Update()
End If
End Sub
End Class