-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgressControl.vb
More file actions
63 lines (49 loc) · 1.95 KB
/
ProgressControl.vb
File metadata and controls
63 lines (49 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Imports System
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Threading
Namespace Busy
Public Partial Class ProgressControl
Inherits UserControl
Private _IsOperationInProgress As Boolean
Public Property IsOperationInProgress As Boolean
Get
Return _IsOperationInProgress
End Get
Set(ByVal value As Boolean)
_IsOperationInProgress = value
simpleButton1.Enabled = Not value
End Set
End Property
Private Const INT_filesCount As Integer = 500
Private Const INT_operationTime As Integer = 10
Public Sub New()
InitializeComponent()
End Sub
Private Shared Sub CopyFile()
Thread.Sleep(INT_operationTime)
End Sub
Private Sub UpdateProgressBar(ByVal value As Integer)
progressBarControl1.EditValue = value
End Sub
Private Sub backgroundWorker_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
For i As Integer = 1 To INT_filesCount
Call CopyFile()
Dim progress As Integer = i * 100 \ INT_filesCount
backgroundWorker.ReportProgress(progress)
Next
End Sub
Private Sub backgroundWorker_ProgressChanged(ByVal sender As Object, ByVal e As ProgressChangedEventArgs)
UpdateProgressBar(e.ProgressPercentage)
End Sub
Private Sub backgroundWorker_Completed(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs)
UpdateProgressBar(0)
IsOperationInProgress = False
End Sub
Private Sub simpleButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
IsOperationInProgress = True
backgroundWorker.RunWorkerAsync()
End Sub
End Class
End Namespace