當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET AsyncCompletedEventArgs類代碼示例

本文整理匯總了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
開發者ID:VB.NET開發者,項目名稱:System.ComponentModel,代碼行數:8,代碼來源:AsyncCompletedEventArgs

示例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
開發者ID:VB.NET開發者,項目名稱:System.ComponentModel,代碼行數:50,代碼來源:AsyncCompletedEventArgs


注:本文中的System.ComponentModel.AsyncCompletedEventArgs類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。