In my windows phone application I am using singleton classes for sending and receiving web request and response. So in my current implementation I will call the web request from viewmodel along with an Action<> delegate. For retrieving error call back and it is working fine for me. My issue is that when I fast app switch the application, the web request cancels and it returns a web error. I need to get this web exception in my view model. How can I get this response by using the Func<> delegate? Please anyone help me to solve this issue.
// viewmodel code
private void Login()
{
LoginContoller.Instance.Login(userName, password, ErrorCallbackCompleted);
}
//callback
private void ErrorCallbackCompleted()
{
}
// code inside singleton class
public static Action ErrorCallbackResponse;
public void Login (string userName, string password, Action errorCallback)
{
ErrorCallbackResponse = errorCallback;
}
// This method will be invoked from the error callback of web request class
public void GetErrorCallBack(Exception ex)
{
ErrorCallbackResponse();
//I need to pass this ex object to my viewmodel using Func<>
}
1 Answer