스레드로 사용할 함수내에 다음과같이 입력함.
CheckForIllegalCrossThreadCalls = False
예제
Imports System.Threading
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MessageBox.Show("This is the main thread")
End Sub
Private Sub ThreadTask()
CheckForIllegalCrossThreadCalls = False
Dim stp As Integer
Dim newval As Integer
Dim rnd As New Random()
Do
stp = ProgressBar1.Step * rnd.Next(-1, 2)
newval = ProgressBar1.Value + stp
If newval > ProgressBar1.Maximum Then
newval = ProgressBar1.Maximum
ElseIf newval < ProgressBar1.Minimum Then
newval = ProgressBar1.Minimum
End If
ProgressBar1.Value = newval
Thread.Sleep(100)
Loop
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim trd As Thread = New Thread(AddressOf ThreadTask)
trd.IsBackground = True
trd.Start()
End Sub
End Class
'프로그래밍언어 > VB.NET' 카테고리의 다른 글
윈도우 서비스에 프로그램을 등록및 삭제하는 방법. (0) | 2017.05.03 |
---|---|
윈도우서비스 종료& 시작 (0) | 2017.03.06 |
CPU온도 가져오기 (0) | 2016.10.09 |
webbrowser 체크박스 체크 (0) | 2014.11.05 |
프로세스종료 (0) | 2014.10.19 |