कोई मतभेद के रूप में BeginInvoke
विधि एक निजी LegacyBeginInvokeImpl
विधि जो itslef निजी विधि InvokeAsyncImpl
(विधि InvokeAsync
द्वारा प्रयोग किया जाता कॉल कॉल कर रहे हैं)। तो यह मूल रूप से एक ही बात है। ऐसा लगता है कि यह एक साधारण रिफैक्टरिंग है, हालांकि यह अजीब है कि BeginInvoke
विधियों को अप्रचलित के रूप में फ़्लैग नहीं किया गया था।
BeginInvoke:
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;
}
वर्तमान में मुझे BeginInvoke का उपयोग करके अपेक्षित काम करने वाले अपरिपक्व अपवाद मिल रहे हैं (DispatcherUnh दोनों को ट्रिगर करना प्रेषक और AppDomain.CurrentDomain.UnhandledException पर AndledException), लेकिन InvokeAsync पर unhandled अपवाद चुपचाप निगल रहे हैं। InvokeAsync से कार्य को जारी रखने के लिए कुछ अपवादों के साथ कार्य को जारी रखना एक वैध काम प्रतीत होता है। – Lamarth
'BeginInvoke' ["असीमित प्रोग्रामिंग मॉडल"] (https://msdn.microsoft.com/en-us/library/ms228963 (v = vs.110) .aspx) के बाद पैटर्न किया गया है .NET में जो' BeginSomething का उपयोग करता है 'और' एंडसोमिंग 'विधियों के रूप में एसिंक्रोनस ऑपरेशंस। संभवतः यही कारण है कि इसे बहिष्कृत या अप्रचलित नामित नहीं किया गया था। सिवाय इसके कि 'प्रारंभ'/'अंत 'सम्मेलन' IAsyncResult' का उपयोग करने के लिए है, और' BeginInvoke' नहीं है, न ही कोई 'EndInvoke' है, इसलिए यह पहली जगह में अनिवार्य था। – sidbushes