assume the code is correct and webservice timeout occurs.
The problem :
- The system crashes and can not display the error message.
How to display error message? So I can provide an alternative to user when there is an error?
1) I add this Class in the project : public class MyClass { public static async Task LogInSuccess() { try { -- calling a web service here } catch (System.Exception _ex) { _strErrorMsg = _ex.InnerException.Message; throw new Exception("LogInSuccess() " + _strErrorMsg); } } } --- In the MainPage, 2) private async void SetUp () { -- code for doing setUp task-- CallWebSvc(); } 3) private void CallWebSvc() { bool ShowError = false; System.Exception MyException = new Exception(); try { -- calling a web service thru the MyClass System.Threading.Tasks.Task _blnLogInSuccess = MyClass.LogInSuccess(); await _blnLogInSuccess; if (_blnLogInSuccess.IsCompleted) { g_blnLoginStatus = _blnLogInSuccess.Result; } } catch (System.Exception _ex) { ShowError = true; MyException = ex; } if (ShowError) { var MyMessageBox = new Windows.UI.Popups.MessageDialog("Remote Login Error:" + MyException.Message, "Start Login" ); await MyMessageBox.ShowAsync(); } }