-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.vb
More file actions
51 lines (45 loc) · 1.96 KB
/
Form1.vb
File metadata and controls
51 lines (45 loc) · 1.96 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
Imports System
Imports System.Threading
Imports System.Windows.Forms
Imports DevExpress.Spreadsheet
Namespace WorkbookProgressSample
Public Partial Class Form1
Inherits Form
Private cancellationSource As CancellationTokenSource
Public Sub New()
InitializeComponent()
End Sub
Private Async Sub RunCancel_Click(ByVal sender As Object, ByVal e As EventArgs)
If cancellationSource IsNot Nothing Then
cancellationSource.Cancel()
Else
progressBarLoad.Value = 0
progressBarExport.Value = 0
btnRunCancel.Text = "Cancel"
cancellationSource = New CancellationTokenSource()
Try
Using workbook As Workbook = New Workbook()
Await workbook.LoadDocumentAsync("Document.xlsx", cancellationSource.Token, New Progress(Of Integer)(Sub(progress)
progressBarLoad.Value = progress
progressBarLoad.Refresh()
End Sub))
Await workbook.ExportToPdfAsync("Result.pdf", cancellationSource.Token, New Progress(Of Integer)(Sub(progress)
progressBarExport.Value = progress
progressBarExport.Refresh()
End Sub))
End Using
Catch __unusedOperationCanceledException1__ As OperationCanceledException
progressBarLoad.Value = 0
progressBarExport.Value = 0
Finally
cancellationSource.Dispose()
cancellationSource = Nothing
btnRunCancel.Text = "Run"
End Try
End If
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs)
cancellationSource?.Cancel()
End Sub
End Class
End Namespace