示例#1
0
        public static void ExecuteAsync(this UIViewController contrller,
                                        Action action,
                                        Action successHandler, Action <Exception> errorHandler)
        {
            var loadingOverlay = new LoadingOverlay(contrller.View.Frame);

            contrller.View.Add(loadingOverlay);
            Task.Factory.StartNew(() =>
            {
                try {
                    action();
                } catch (Exception exception) {
                    contrller.InvokeOnMainThread(() => {
                        RemoveLoadingOverlay(loadingOverlay);
                        errorHandler(exception);
                        new UIAlertView("Error", exception.Message, null, "OK",
                                        null).Show();
                    });
                }
                contrller.InvokeOnMainThread(() => {
                    RemoveLoadingOverlay(loadingOverlay);
                    successHandler();
                }
                                             );
            });
        }
示例#2
0
        public static void ExecuteAsync(this UIViewController contrller, 
		                                Action action,
		                                Action successHandler, Action<Exception> errorHandler)
        {
            var loadingOverlay = new LoadingOverlay (contrller.View.Frame);
            contrller.View.Add (loadingOverlay);
            Task.Factory.StartNew (() =>
            {
                try {
                    action ();
                } catch (Exception exception) {
                    contrller.InvokeOnMainThread (() => {
                        RemoveLoadingOverlay (loadingOverlay);
                        errorHandler(exception);
                        new UIAlertView ("Error", exception.Message, null, "OK",
                                         null).Show ();
                    });
                }
                contrller.InvokeOnMainThread (() => {
                    RemoveLoadingOverlay (loadingOverlay);
                    successHandler ();
                }
                );
            });
        }
示例#3
0
 static void RemoveLoadingOverlay(LoadingOverlay loadingOverlay)
 {
     loadingOverlay.Hide();
     loadingOverlay.RemoveFromSuperview();
 }
示例#4
0
 static void RemoveLoadingOverlay(LoadingOverlay loadingOverlay)
 {
     loadingOverlay.Hide ();
     loadingOverlay.RemoveFromSuperview ();
 }