???? ??? ??????? ????? ????? ?????? ??????? ?? ????? Microsoft Visual Basic .NET ?? Microsoft Windows 2005 Visual Basic. ???? ????? ?????
System.Threading ?????? ???? ??? ?? ???? ???? ????? ?? ?????? ???????.
???????
???? ??????? ??????? ??????? ?????? ??? ????? ?????? ???????? ?????? ? ??? ??????? ???? ???????:
- Microsoft Windows 2000 ?? Microsoft Windows XP
- Microsoft Visual Basic .NET ?? Microsoft Visual Basic 2005
????? ??? ??????? ??? ??????? ??? ???????? ???????:
- ????? Visual Basic .NET ?? ????? Visual Basic 2005
- Visual Studio .NET ?? ???? ??????? ????????? Visual Studio 2005 (IDE)
- ?????? ?????? ?? ???????? "?" ???? ???????
- ?????? ?????? ?? Visual Basic .NET ?? Visual Basic 2005
????? ????? Visual Basic .NET ?? 2005 Visual Basic ?? ?????? ???????
- ??? ????? Microsoft Visual Studio .NET ?? Microsoft Visual Studio 2005.
- ????? ????? Visual Basic ????? Windows ???? ???? ThreadWinApp.
- ????? ???? ???? ?? ??? ???????. ????? ???? Button1 ???? ???????.
- ????? ???? ProgressBar ??? ???????. ????? ???? ?????? ProgressBar1 ???? ???????.
- ???? ??? ?????? ?????? ??? ??????? ?? ???? ??? ??? ????????? ????????.
- ????? ??????? ??????? ??? ????? ?????:
- ????? ????? ????? ?????? ???? ?? ??? Button1:
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
- ????? ??????? ?????? ??? ??? Form1:
- ??? ??????? ?????? ??? ??? Form1:
Private Sub ThreadTask()
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
??????: ??? ?? ??? underlies ???? ???????. ??? ????? ?? infinite ???? ??? ?????? ???????? ?? decrements ?????? ?? ProgressBar1 ????????? ?? 100 ???? ????? ??? ?? ?????. - ????? ????? ????? Load ??????? ?? ??? Form1. ??? ???????? ???????? ????? ???? ????? ???? ???? ???? ??????? ???? ????? ????? ? ?? ??? ????? ???? ???????.
Private Sub Form1_Load( _
ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
trd = New Thread(AddressOf ThreadTask)
trd.IsBackground = True
trd.Start()
End Sub
???? ?? ??? ????
- ?????? ??????? ???????. ???? ???? ?????? ?? ???? ?????? ???? ??????. ??? ?? ???? ????? ???? ?? ???????.
- ???? ?? ???? ??????? ??????? ?????? ?? ???? ??????? ???? ?????? ???? ProgressBar ? ???? ??? ???? ?? ???????. ???? ????? ???? ??????? ???????: ????? ??? ???????. ???? ?? ?????? ???????? ?? ???? ?????? ????? ?? ?????.
??????? ??????? ????????
?? ??????? ???? ??????? ???? ?? ?????? ?????? ????? ?????? ??? ?????? ??? ??????? ????????. ????? ?? ?????????? ???? ????
SyncLock ????????? ??? ????? ?? ????? "??????? Visual Basic ??? ??????".
???? ???????: 315577 - ????? ??? ??????: 15/?? ??????/1427 - ??????: 4.3
????? ???
- Microsoft Visual Basic 2005
- Microsoft Visual Basic .NET 2003 Standard Edition
- Microsoft Visual Basic .NET 2002 Standard Edition
| kbmt kbvs2005swept kbvs2005applies kbhowtomaster KB315577 KbMtar |
????? ???????: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????
315577
(http://support.microsoft.com/kb/315577/en-us/
)