WorkflowInstance.GetWorkflowQueueData Yöntem
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Bu iş akışı örneğiyle ilişkili iş akışı kuyrukları için bekleyen öğeleri ve abone olunan etkinlikleri içeren bir nesne koleksiyonunu WorkflowQueueInfo alır.
public:
System::Collections::ObjectModel::ReadOnlyCollection<System::Workflow::Runtime::WorkflowQueueInfo ^> ^ GetWorkflowQueueData();
public System.Collections.ObjectModel.ReadOnlyCollection<System.Workflow.Runtime.WorkflowQueueInfo> GetWorkflowQueueData();
member this.GetWorkflowQueueData : unit -> System.Collections.ObjectModel.ReadOnlyCollection<System.Workflow.Runtime.WorkflowQueueInfo>
Public Function GetWorkflowQueueData () As ReadOnlyCollection(Of WorkflowQueueInfo)
Nesnelerden ReadOnlyCollection<T> oluşan WorkflowQueueInfo bir.
İş akışı çalışma zamanı altyapısı çalışmıyor.
Aşağıdaki kod örneği, bir WorkflowInstance nesneyle ilişkili tüm iş akışı kuyruklarının durumu hakkında bilgi almak için yöntemini nasıl kullanabileceğinizi GetWorkflowQueueData gösterir. Olay gerçekleştiğinde WorkflowIdled , OnWorkflowIdled
bu örnekte tanımlanan yöntem çağrılır. özelliği kullanılarak hangi iş akışının WorkflowInstance boşta olduğunu belirler ve ardından yöntemini çağırarak GetWorkflowQueueData iş akışı örneği için kuyruğa alınmış öğeler koleksiyonunu alır. Kod, iş akışının boşta olduğu olayı hangi etkinliğin beklediğini belirlemek için koleksiyon üzerinde yinelenir. Ardından, olay kuyruğu öğesinin adıyla birlikte yöntemini kullanarak EnqueueItem iş akışı kuyruğuna bir özel durum gönderir.
Bu kod örneği, Program.cs dosyasından İş Akışı SDK'sını İptal Etme örneğinin bir parçasıdır. Daha fazla bilgi için bkz. İş Akışını İptal Etme.
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
GetWorkflowQueueData , her biri WorkflowQueueInfo bu iş akışı örneğiyle ilişkili iş akışı kuyruklarından birinin durumu hakkında bilgi içeren bir nesne koleksiyonu döndürür. WorkflowQueueInfo.Items için WorkflowQueue bekleyen öğeleri içerir ve WorkflowQueueInfo.SubscribedActivityNames üzerinde öğe teslimi WorkflowQueueiçin abone olunan etkinliklerin listesini içerir.
Ürün | Sürümler |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET geri bildirimi
.NET, açık kaynak bir projedir. Geri bildirim sağlamak için bir bağlantı seçin: