示例#1
0
        public static async Task <Exception> BusyTask(this IBusy busy, Func <Task> task, string busyMessage = null, bool alertOnException = true)
        {
            Debug.AssertNotNull(busy);
            Debug.AssertNotNull(task);
            if (busy.IsBusy)
            {
                //Debug.Fail("BusyTask called with other BusyTask in progress");
                return(null);
            }

            busy.StartBusy(busyMessage);
            try {
                await task();

                return(null);
            }
            catch (Exception exc) {
                Debug.ExceptionCaught(exc);
                if (alertOnException)
                {
                    await Alerts.ExceptionAlert(exc);
                }
                return(exc);
            }
            finally {
                busy.EndBusy();
            }
        }
示例#2
0
        public static async Task <Exception> BusyTask(this IBusy busy, Action action, string busyMessage = null, bool alertOnException = true)
        {
            Debug.AssertNotNull(busy);
            Debug.AssertNotNull(action);
            if (busy.IsBusy)
            {
                //Debug.Fail("Can not perfotm another busy task while in busy state");
                return(null);
            }

            busy.StartBusy(busyMessage);
            try {
                action();
                return(null);
            }
            catch (Exception exc) {
                Debug.ExceptionCaught(exc);
                if (alertOnException)
                {
                    await Alerts.ExceptionAlert(exc);
                }
                return(exc);
            }
            finally {
                busy.EndBusy();
            }
        }