멀티스래딩 타이머.
*
Imports System.Threading
Public Class Form1

Public KeepAliveDelegate As Threading.TimerCallback
Public KeepAlliveTimer As System.Threading.Timer
Dim count As Integer

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

KeepAliveDelegate = AddressOf KeepAlliveTimerHandler

End Sub

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

count = 0
KeepAlliveTimer = New System.Threading.Timer(KeepAliveDelegate, Nothing, 1000, 1000)
KeepAlliveTimer.Change(1000, 1000)

End Sub


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

KeepAlliveTimer.Change(0, System.Threading.Timeout.Infinite)
End Sub

Private Sub KeepAlliveTimerHandler(ByVal state As Object)

AccessControl()

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

KeepAlliveTimer = New System.Threading.Timer(KeepAliveDelegate, Nothing, 0, 1000)

End Sub

Private Sub AccessControl()

If Me.InvokeRequired Then
Me.Invoke(New MethodInvoker(AddressOf AccessControl))
Else
count = count + 1
Label1.Text = count.ToString
End If
End Sub

End Class

멀티 스래딩 타이머.

코드를 줄일수 있는 방법이 있을까여??

멀티스래딩 활용방법은 몰까여??

이 게시물을

공유하기

SEARCH

MENU NAVIGATION