本文整理匯總了VB.NET中System.ComponentModel.AsyncCompletedEventArgs類的典型用法代碼示例。如果您正苦於以下問題:VB.NET AsyncCompletedEventArgs類的具體用法?VB.NET AsyncCompletedEventArgs怎麽用?VB.NET AsyncCompletedEventArgs使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了AsyncCompletedEventArgs類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1:
' 導入命名空間
Imports System.Collections
Imports System.Collections.Specialized
Imports System.ComponentModel
Imports System.Drawing
Imports System.Globalization
Imports System.Threading
Imports System.Windows.Forms
示例2: CType
' This event handler updates the ListView control when the
' PrimeNumberCalculator raises the CalculatePrimeCompleted
' event. The ListView item is updated with the appropriate
' outcome of the calculation: Canceled, Error, or result.
Private Sub primeNumberCalculator1_CalculatePrimeCompleted( _
ByVal sender As Object, _
ByVal e As CalculatePrimeCompletedEventArgs) _
Handles primeNumberCalculator1.CalculatePrimeCompleted
Dim taskId As Guid = CType(e.UserState, Guid)
If e.Cancelled Then
Dim result As String = "Canceled"
Dim lvi As ListViewItem = UpdateListViewItem( _
taskId, _
result)
If (lvi IsNot Nothing) Then
lvi.BackColor = Color.Pink
lvi.Tag = Nothing
End If
ElseIf e.Error IsNot Nothing Then
Dim result As String = "Error"
Dim lvi As ListViewItem = UpdateListViewItem( _
taskId, result)
If (lvi IsNot Nothing) Then
lvi.BackColor = Color.Red
lvi.ForeColor = Color.White
lvi.Tag = Nothing
End If
Else
Dim result As Boolean = e.IsPrime
Dim lvi As ListViewItem = UpdateListViewItem( _
taskId, _
result, _
e.FirstDivisor)
If (lvi IsNot Nothing) Then
lvi.BackColor = Color.LightGray
lvi.Tag = Nothing
End If
End If
End Sub