BeginInvoke
yöntem itslef özel yöntem InvokeAsyncImpl
(InvokeAsync
kullandığı yöntemini çağıran özel LegacyBeginInvokeImpl
yöntemini çağırır hiçbir fark yoktur). Yani temelde aynı şey. Basit bir refactoring gibi görünüyor, ancak garip BeginInvoke
yöntemleri eskimiş olarak işaret değildi.
Beginınvoke:
public DispatcherOperation BeginInvoke(DispatcherPriority priority, Delegate method)
{
return this.LegacyBeginInvokeImpl(priority, method, null, 0);
}
private DispatcherOperation LegacyBeginInvokeImpl(DispatcherPriority priority, Delegate method, object args, int numArgs)
{
Dispatcher.ValidatePriority(priority, "priority");
if (method == null)
{
throw new ArgumentNullException("method");
}
DispatcherOperation dispatcherOperation = new DispatcherOperation(this, method, priority, args, numArgs);
this.InvokeAsyncImpl(dispatcherOperation, CancellationToken.None);
return dispatcherOperation;
}
InvokeAsync:
public DispatcherOperation InvokeAsync(Action callback, DispatcherPriority priority)
{
return this.InvokeAsync(callback, priority, CancellationToken.None);
}
public DispatcherOperation InvokeAsync(Action callback, DispatcherPriority priority, CancellationToken cancellationToken)
{
if (callback == null)
{
throw new ArgumentNullException("callback");
}
Dispatcher.ValidatePriority(priority, "priority");
DispatcherOperation dispatcherOperation = new DispatcherOperation(this, priority, callback);
this.InvokeAsyncImpl(dispatcherOperation, cancellationToken);
return dispatcherOperation;
}
Şu anda, BeginInvoke kullanarak beklenmedik şekilde çalışan işlenmeyen istisnalar alıyorum (her iki DispatcherUnh tetikleniyor) dağıtıcı ve AppDomain.CurrentDomain.UnhandledException üzerinde andledException, ancak InvokeAsync üzerinde işlenmeyen özel durumlar sessizce yutuluyor. InvokeAsync'ten gelen görevi, özel durumları yakalayacak bir şeyle sürdürmek, geçerli bir çalışma gibi görünüyor. – Lamarth
'BeginInvoke', .NET'te' BeginSomething öğesini kullanan ["Eş Zamanlı Programlama Modeli"] 'nden (https://msdn.microsoft.com/en-us/library/ms228963 (v = vs.110) .aspx) sonra biçimlendirilmiştir Eşzamansız işlemler için 've' EndSomething' yöntemleri. Muhtemelen bu yüzden kullanımdan kaldırılmış veya eski değil. “Begin”/“End” sözleşmesinin “IAsyncResult” ve “BeginInvoke” kelimelerini kullanması dışında herhangi bir “EndInvoke” özelliği yoktur, bu yüzden ilk etapta gereksizdir. – sidbushes