WorkflowEventArgs Kelas

Definisi

Perhatian

The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*

Menyediakan data untuk peristiwa alur kerja.

public ref class WorkflowEventArgs : EventArgs
public class WorkflowEventArgs : EventArgs
[System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
public class WorkflowEventArgs : EventArgs
type WorkflowEventArgs = class
    inherit EventArgs
[<System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")>]
type WorkflowEventArgs = class
    inherit EventArgs
Public Class WorkflowEventArgs
Inherits EventArgs
Warisan
WorkflowEventArgs
Turunan
Atribut

Contoh

Contoh kode berikut menunjukkan cara mendapatkan WorkflowInstance objek menggunakan WorkflowInstance properti saat metode penanganan aktivitas dipanggil. WorkflowIdled Ketika peristiwa terjadi, metode yang OnWorkflowIdled ditentukan dalam contoh ini dipanggil. Ini menentukan alur kerja mana yang diam menggunakan WorkflowInstance properti dan kemudian mendapatkan kumpulan item antrean untuk instans alur kerja dengan memanggil GetWorkflowQueueData metode . Kode berulang di atas koleksi untuk menentukan aktivitas mana yang menunggu peristiwa yang menganggur alur kerja. Kemudian mengirimkan pengecualian ke antrean alur kerja menggunakan EnqueueItem metode bersama dengan nama item antrean peristiwa.

Contoh kode ini adalah bagian dari Membatalkan Sampel SDK Alur Kerja dari file Program.cs. Untuk informasi selengkapnya, lihat Membatalkan Alur Kerja.

static void OnWorkflowIdled(object sender, WorkflowEventArgs e)
{
    WorkflowInstance workflow = e.WorkflowInstance;

    Console.WriteLine("\n...waiting for 3 seconds... \n");
    Thread.Sleep(3000);

    // what activity is blocking the workflow
    ReadOnlyCollection<WorkflowQueueInfo> wqi = workflow.GetWorkflowQueueData();
    foreach (WorkflowQueueInfo q in wqi)
    {
        EventQueueName eq = q.QueueName as EventQueueName;
        if (eq != null)
        {
            // get activity that is waiting for event
            ReadOnlyCollection<string> blockedActivity = q.SubscribedActivityNames;
            Console.WriteLine("Host: Workflow is blocked on " + blockedActivity[0]);

            // this event is never going to arrive eg. employee left the company
            // lets send an exception to this queue
            // it will either be handled by exception handler that was modeled in workflow
            // or the runtime will unwind running compensation handlers and exit the workflow
            Console.WriteLine("Host: This event is not going to arrive");
            Console.WriteLine("Host: Cancel workflow with unhandled exception");
            workflow.EnqueueItem(q.QueueName, new Exception("ExitWorkflowException"), null, null);
        }
    }
}
Shared Sub OnWorkflowIdled(ByVal sender As Object, ByVal e As WorkflowEventArgs)
    Dim workflow As WorkflowInstance = e.WorkflowInstance

    Console.WriteLine(vbCrLf + "...waiting for 3 seconds... " + vbCrLf)
    Thread.Sleep(3000)

    ' what activity is blocking the workflow
    Dim wqi As ReadOnlyCollection(Of WorkflowQueueInfo) = workflow.GetWorkflowQueueData()
    For Each q As WorkflowQueueInfo In wqi

        Dim eq As EventQueueName = TryCast(q.QueueName, EventQueueName)

        If eq IsNot Nothing Then
            ' get activity that is waiting for event
            Dim blockedActivity As ReadOnlyCollection(Of String) = q.SubscribedActivityNames
            Console.WriteLine("Host: Workflow is blocked on " + blockedActivity(0))

            ' this event is never going to arrive eg. employee left the company
            ' lets send an exception to this queue
            ' it will either be handled by exception handler that was modeled in workflow
            ' or the runtime will unwind running compensation handlers and exit the workflow
            Console.WriteLine("Host: This event is not going to arrive")
            Console.WriteLine("Host: Cancel workflow with unhandled exception")
            workflow.EnqueueItem(q.QueueName, New Exception("ExitWorkflowException"), Nothing, Nothing)
        End If
    Next
End Sub

Keterangan

Catatan

Materi ini membahas jenis dan namespace layanan yang sudah tidak digunakan. Untuk informasi selengkapnya, lihat Jenis yang Tidak Digunakan Lagi di Windows Workflow Foundation 4.5.

Peristiwa alur kerja dikaitkan dengan instans alur kerja. WorkflowEventArgs berisi yang WorkflowInstance terkait dengan peristiwa alur kerja. Atau WorkflowEventArgs objek yang berasal dari WorkflowEventArgs kelas menyediakan data untuk semua peristiwa alur kerja di WorkflowRuntime kelas . WorkflowEventArgs adalah kelas dasar untuk WorkflowCompletedEventArgs, WorkflowSuspendedEventArgs, dan WorkflowTerminatedEventArgs.

Properti

WorkflowInstance
Kedaluwarsa.

Mendapatkan instans alur kerja yang terkait dengan peristiwa alur kerja.

Metode

Equals(Object)
Kedaluwarsa.

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
GetHashCode()
Kedaluwarsa.

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetType()
Kedaluwarsa.

Mendapatkan dari instans Type saat ini.

(Diperoleh dari Object)
MemberwiseClone()
Kedaluwarsa.

Membuat salinan dangkal dari saat ini Object.

(Diperoleh dari Object)
ToString()
Kedaluwarsa.

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Berlaku untuk

Lihat juga