本文整理汇总了VB.NET中System.ComponentModel.AsyncCompletedEventArgs.UserState属性的典型用法代码示例。如果您正苦于以下问题:VB.NET AsyncCompletedEventArgs.UserState属性的具体用法?VB.NET AsyncCompletedEventArgs.UserState怎么用?VB.NET AsyncCompletedEventArgs.UserState使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.ComponentModel.AsyncCompletedEventArgs
的用法示例。
在下文中一共展示了AsyncCompletedEventArgs.UserState属性的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