मैं अपने अतुल्यकालिक प्रोग्रामिंग (BeginInvoke/EndInvoke) में एक अपवाद संचालन दृष्टिकोण करना चाहते हैं जिसमें अगर धागा (BeginInvoke) में से किसी एक में विफल रहता है, तो मैं अन्य सभी asynchrounous प्रसंस्करण धागा काम करना बंद करना चाहते हैं। कृपया ?, कुछ समाधान का सुझाव नीचे मैं अपने नमूना कोड भी संलग्न कर रहा हूँ:असीमित मल्टीथ्रेडिंग अपवाद हैंडलिंग?
public List<ThreadResultDto> SendMailAsynch(List<ThreadRequestDto> requestDto)
{
List<ThreadResultDto> resultDto = new List<ThreadResultDto>();
List<IAsyncResult> asyncResults = new List<IAsyncResult>();
foreach (ThreadRequestDto t in requestDto)
{
//Create a delegate.
DoSomeAsynchWorkDelegate del = new DoSomeAsynchWorkDelegate(DoSomeAsynchWork);
// Initiate the asynchronous call
IAsyncResult a = del.BeginInvoke(t,null, del);
//IAsyncResult a = del.BeginInvoke(t, null,null);
asyncResults.Add(a);
}
foreach (IAsyncResult ar in asyncResults)
{
// wait for each one to complete, then call EndInvoke, passing in the IAsyncResult.
// We cast ar.AsyncState to a DoSomeAsynchWorkDelegate, as we passed it in as the second parameter to BeginInvoke.
ar.AsyncWaitHandle.WaitOne();
//AsyncState property of IAsyncResult is used to get the delegate that was used to call that method
DoSomeAsynchWorkDelegate del = (DoSomeAsynchWorkDelegate)ar.AsyncState;
// Call EndInvoke to get the result. Add the result to the list of items.
resultDto.Add(del.EndInvoke(ar));
}
return resultDto;
}
FYI करें, अतुल्यकालिक की आम तौर पर स्वीकार संक्षिप्त नाम Async है, नहीं Asynch :) –