I am using WCF Async calls in my project and i am using Client side asynchronous methods. I have a scenario like below -
//Code in Business Layer and this method is called from Web layer
private void GetGeneralNews()
{
client.BeginGetGeneralNewsFeed(GeneralNewsCallback, null);
}
//Call Back Method
private static void GeneralNewsCallback(IAsyncResult asyncResult)
{
string response = string.Empty;
try
{
response = client.EndGetGeneralNewsFeed(asyncResult);
}
catch(Exception ex)
{
throw ex; // Here is the problem. It does not throw the exception to the web layer instead it will suppress the error.
}
}
So as shown in the above code snippet it does not throw the exception from business layer to web layer as it will be suppressed here in business layer itself.
I checked in some of the blogs and sites they are suggesting to go for async and await approach, as i have .NET 4.0 framework and i am seeing "Generate task-based Operations" option disabled. So if there are any options using "IAsyncResult" (Begin & End in client side) please let me know. If there are any other approaches also welcome.
Kindly someone help me.
Thanks.