ผมทำตัว setup project พอเอาไปลงเครื่องอื่น แล้วมันขึ้นแบบนี้อ่ะครับ
ตอนแรกนกว่าเป็นเพราะ win xp
เลยเอากลับมา test กับเครื่องอื่น xp86,xp64,7 86,7 64 ก็เป็นบางเครื่อง
ฐานข้อมูล mysql ต่อด้วย ip ต่อipวงเดียวกัน
Imports System.Threading
Public Class frmBioKeyThreadDelegate
Private Delegate Sub DialogCallBack(ByVal msg As String)
Private Delegate Sub ThreadFinishedCallBack()
Private _DialogCallBack As DialogCallBack
Private _DialogCallBack2 As DialogCallBack
Private _threadFinishedCallBack As ThreadFinishedCallBack
Private _IsThreadRunning As Boolean = False
Private _ManualResetEvent As ManualResetEvent
Public Sub New()
InitializeComponent()
_DialogCallBack = New DialogCallBack(AddressOf WriteCountLog)
_DialogCallBack2 = New DialogCallBack(AddressOf WriteStatusLog)
_threadFinishedCallBack = New ThreadFinishedCallBack(AddressOf ThreadFinished)
_ManualResetEvent = New ManualResetEvent(False)
End Sub
Private Sub btnCounter_Click(sender As System.Object, e As System.EventArgs) Handles btnCounter.Click
If _IsThreadRunning Then
_IsThreadRunning = False
_ManualResetEvent.Set()
btnCounter.Text = "Start/Stop/Pause"
Else
lblCounter.Text = "0"
_IsThreadRunning = True
btnCounter.Text = "Pause/Stop"
_ManualResetEvent.Reset()
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf Test_ThreadProc), New Object())
End If
End Sub
Private Sub WriteCountLog(ByVal msg1 As Integer)
lblCounter.Text = msg1
End Sub
Private Sub WriteStatusLog(ByVal msg1 As String)
lblThreadStatus.Text = msg1
End Sub
Private Sub ThreadFinished()
Control.CheckForIllegalCrossThreadCalls = False
btnCounter.Text = "Start/Pause/Stop"
_IsThreadRunning = False
WriteCountLog(0)
WriteStatusLog("Thread Status : Stop")
End Sub
Private Sub Test_ThreadProc(ByVal stateInfo As Object)
lblThreadStatus.Invoke(_DialogCallBack2, New Object() {"Thread Status : Started"})
Try
Dim i As Integer = 0
While (i < 1000001) AndAlso Not _ManualResetEvent.WaitOne(0) 'For Start/Pause/Stop
WriteCountLog(i)
Thread.Sleep(123456789)
i += 1
End While
Catch exp As Exception
lblThreadStatus.Invoke(_DialogCallBack2, New Object() {"Exception caught:" & exp.Message})
Finally
ThreadFinished()
End Try
End Sub
End Class