WorkflowRuntime.ServicesExceptionNotHandled Olay

Tanım

sınıfından türetilen WorkflowRuntimeService bir hizmet çağırdığında RaiseServicesExceptionNotHandledEvent(Exception, Guid)gerçekleşir.

public:
 event EventHandler<System::Workflow::Runtime::ServicesExceptionNotHandledEventArgs ^> ^ ServicesExceptionNotHandled;
public event EventHandler<System.Workflow.Runtime.ServicesExceptionNotHandledEventArgs> ServicesExceptionNotHandled;
member this.ServicesExceptionNotHandled : EventHandler<System.Workflow.Runtime.ServicesExceptionNotHandledEventArgs> 
Public Custom Event ServicesExceptionNotHandled As EventHandler(Of ServicesExceptionNotHandledEventArgs) 
Public Event ServicesExceptionNotHandled As EventHandler(Of ServicesExceptionNotHandledEventArgs) 

Olay Türü

Örnekler

Aşağıdaki kod örneği, bir iş akışı konağından işlevselliğin nasıl kullanılacağını WorkflowRuntime gösterir. Kod adlı bir yöntem OnExceptionNotHandledolan olay işleyicisiyle ilişkilendirirServicesExceptionNotHandled.

Bu kod örneği , Özel Kalıcılık Hizmeti Örneğinin bir parçasıdır.

static void Main()
{
    using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
    {
        try
        {
            // engine will unload workflow instance when it is idle
            workflowRuntime.AddService(new FilePersistenceService(true));

            workflowRuntime.WorkflowCreated += OnWorkflowCreated;
            workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;
            workflowRuntime.WorkflowIdled += OnWorkflowIdle;
            workflowRuntime.WorkflowUnloaded += OnWorkflowUnload;
            workflowRuntime.WorkflowLoaded += OnWorkflowLoad;
            workflowRuntime.WorkflowTerminated += OnWorkflowTerminated;
            workflowRuntime.ServicesExceptionNotHandled += OnExceptionNotHandled;

            workflowRuntime.CreateWorkflow(typeof(PersistenceServiceWorkflow)).Start();

            waitHandle.WaitOne();
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception \n\t Source: {0} \n\t Message: {1}", e.Source, e.Message);
        }
        finally
        {
            workflowRuntime.StopRuntime();
            Console.WriteLine("Workflow runtime stopped, program exiting... \n");
        }
    }
}
Shared Sub Main()

    Using currentWorkflowRuntime As New WorkflowRuntime()
        Try

            ' engine will unload workflow instance when it is idle
            currentWorkflowRuntime.AddService(New FilePersistenceService(True))

            AddHandler currentWorkflowRuntime.WorkflowCreated, AddressOf OnWorkflowCreated
            AddHandler currentWorkflowRuntime.WorkflowCompleted, AddressOf OnWorkflowCompleted
            AddHandler currentWorkflowRuntime.WorkflowIdled, AddressOf OnWorkflowIdled
            AddHandler currentWorkflowRuntime.WorkflowUnloaded, AddressOf OnWorkflowUnloaded
            AddHandler currentWorkflowRuntime.WorkflowLoaded, AddressOf OnWorkflowLoaded
            AddHandler currentWorkflowRuntime.WorkflowTerminated, AddressOf OnWorkflowTerminated
            AddHandler currentWorkflowRuntime.ServicesExceptionNotHandled, AddressOf OnExceptionNotHandled

            currentWorkflowRuntime.CreateWorkflow(GetType(PersistenceServiceWorkflow)).Start()

            waitHandle.WaitOne()

        Catch e As Exception
            Console.WriteLine("Exception \n\t Source: 0} \n\t Message: 1}", e.Source, e.Message)
        Finally
            currentWorkflowRuntime.StopRuntime()
            Console.WriteLine("Workflow runtime stopped, program exiting... \n")
        End Try
    End Using
End Sub

Açıklamalar

sınıfından WorkflowRuntimeService türetilen bir hizmet, aboneleri ServicesExceptionNotHandled yürütmesi sırasında işleyemediği bir özel durumun oluştuğunu olaya bildirmek için yöntemini çağırabilirRaiseServicesExceptionNotHandledEvent. Bir kurtarma mekanizması uygulamak için bu olaya abone olabilirsiniz.

Bu olay, bir iş akışı örneği henüz iş akışı çalışma zamanı altyapısı tarafından oluşturulmadığında ve bir özel durum oluştuğunda oluşturulur. Bu senaryoda, bir konak uygulamaya bir özel durumun oluştuğunu bildirmenin tek yolu bu olayı tetiklemektir. Ancak, iş akışı çalışma zamanı altyapısı bunu doğrudan çağırmaz. Bunun yerine, iş akışı çalışma zamanı altyapısı iş akışı örneğine bir özel durum sunar veya örnek yoksa çağırana geri atılır ve bu durumda aslında bu olayı tetikleyen hizmettir. Kendi kalıcılık veya zamanlayıcı hizmetinizi oluşturursanız, bu olayı temel RaiseServicesExceptionNotHandledEvent yöntem aracılığıyla kendiniz uygulamanız gerekir.

ServicesExceptionNotHandled Olay için, gönderen hizmeti Exception kullanan ve WorkflowEventArgs işlenemeyen iş akışı örneğinin öğesini içerir WorkflowRuntimeGuid.

Olayları işleme hakkında daha fazla bilgi için bkz. Olayları işleme ve oluşturma.

Şunlara uygulanır