Workflow (WF) lifecycle events
<p>If i have following 'Workflow lifecycle events' in my <code>program.cs</code>.</p>

<p>Unable to understand that <code>WaitOne()</code> will wait for which signal to arrive? </p>

<p>Does <code>Completed</code> has the highest priority or <code>idle</code> has the highest priority or whatever signal arrives, it will receive?</p>

<pre><code>app.Run();
syncEvent.WaitOne();



app.PersistableIdle = delegate(WorkflowApplicationIdleEventArgs e)
{
    return PersistableIdleAction.Unload;   
};

app.Unloaded = delegate(WorkflowApplicationEventArgs e)
{
    Console.WriteLine("Workflow {0} Unloaded.", e.InstanceId);  
    syncEvent.Set();
};


app.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
{
    if (e.CompletionState == ActivityInstanceState.Faulted)
    {
        Console.WriteLine("Workflow {0} Terminated.", e.InstanceId);
        Console.WriteLine("Exception: {0}\n{1}",
            e.TerminationException.GetType().FullName,
            e.TerminationException.Message);
    }
    else if (e.CompletionState == ActivityInstanceState.Canceled)
    {
        Console.WriteLine("Workflow {0} Canceled.", e.InstanceId);
    }
    else
    {
        Console.WriteLine("Workflow {0} Completed.", e.InstanceId);
    }
};

app.Aborted = delegate(WorkflowApplicationAbortedEventArgs e)
{
    Console.WriteLine("Workflow {0} Aborted.", e.InstanceId);
    Console.WriteLine("Exception: {0}\n{1}",
        e.Reason.GetType().FullName,
        e.Reason.Message);
};

app.Idle = delegate(WorkflowApplicationIdleEventArgs e)
{
    Console.WriteLine("Workflow {0} Idle.", e.InstanceId);
};

app.OnUnhandledException = delegate(WorkflowApplicationUnhandledExceptionEventArgs e)
{
    Console.WriteLine("OnUnhandledException in Workflow {0}\n{1}",
        e.InstanceId, e.UnhandledException.Message);

    Console.WriteLine("ExceptionSource: {0} - {1}",
        e.ExceptionSource.DisplayName, e.ExceptionSourceInstanceId);
    return UnhandledExceptionAction.Terminate;
};
</code></pre>