Share via


WorkflowApplicationUnhandledExceptionEventArgs Kelas

Definisi

Menyediakan informasi tentang pengecualian yang tidak tertangani yang terjadi dalam instans alur kerja.

public ref class WorkflowApplicationUnhandledExceptionEventArgs : System::Activities::WorkflowApplicationEventArgs
public class WorkflowApplicationUnhandledExceptionEventArgs : System.Activities.WorkflowApplicationEventArgs
type WorkflowApplicationUnhandledExceptionEventArgs = class
    inherit WorkflowApplicationEventArgs
Public Class WorkflowApplicationUnhandledExceptionEventArgs
Inherits WorkflowApplicationEventArgs
Warisan
WorkflowApplicationUnhandledExceptionEventArgs

Contoh

Contoh berikut memanggil alur kerja yang melemparkan pengecualian. Pengecualian tidak ditangani oleh alur kerja dan handler OnUnhandledException dipanggil. WorkflowApplicationUnhandledExceptionEventArgs diperiksa untuk memberikan informasi tentang pengecualian, dan alur kerja dihentikan.

Activity wf = new Sequence
{
    Activities =
     {
         new WriteLine
         {
             Text = "Starting the workflow."
         },
         new Throw
        {
            Exception = new InArgument<Exception>((env) =>
                new ApplicationException("Something unexpected happened."))
        },
        new WriteLine
         {
             Text = "Ending the workflow."
         }
     }
};

WorkflowApplication wfApp = new WorkflowApplication(wf);

wfApp.OnUnhandledException = delegate(WorkflowApplicationUnhandledExceptionEventArgs e)
{
    // Display the unhandled exception.
    Console.WriteLine("OnUnhandledException in Workflow {0}\n{1}",
        e.InstanceId, e.UnhandledException.Message);

    Console.WriteLine("ExceptionSource: {0} - {1}",
        e.ExceptionSource.DisplayName, e.ExceptionSourceInstanceId);

    // Instruct the runtime to terminate the workflow.
    return UnhandledExceptionAction.Terminate;

    // Other choices are UnhandledExceptionAction.Abort and
    // UnhandledExceptionAction.Cancel
};

wfApp.Run();

Keterangan

Jika pengecualian ditampilkan oleh aktivitas dan tidak tertangani, perilaku defaultnya adalah mengakhiri instans alur kerja. Jika ada OnUnhandledException handler, handler dapat mengambil alih perilaku default ini. Handler ini memberi penulis host alur kerja kesempatan untuk memberikan penanganan yang sesuai, seperti pengelogan kustom, membatalkan alur kerja, membatalkan alur kerja, atau mengakhiri alur kerja.

Properti

ExceptionSource

Mendapatkan aktivitas yang merupakan sumber pengecualian yang tidak tertangani.

ExceptionSourceInstanceId

Mendapatkan pengidentifikasi unik instans aktivitas yang merupakan sumber pengecualian yang tidak tertangani.

InstanceId

Pengidentifikasi unik instans alur kerja.

(Diperoleh dari WorkflowApplicationEventArgs)
UnhandledException

Mendapatkan yang tidak tertangani oleh instans Exception alur kerja.

Metode

Equals(Object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
GetHashCode()

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetInstanceExtensions<T>()

Mendapatkan kumpulan ekstensi dari jenis yang ditentukan.

(Diperoleh dari WorkflowApplicationEventArgs)
GetType()

Mendapatkan instans Type saat ini.

(Diperoleh dari Object)
MemberwiseClone()

Membuat salinan dangkal dari yang saat ini Object.

(Diperoleh dari Object)
ToString()

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Berlaku untuk