Ejemplo n.º 1
0
    public static void Start(Action action)
    {
        ASynch.RaiseOnModalAsyncStart();

        if (ASynch.IsEnabled)
        {
            var form = new AsyncForm(() =>
            {
                action();
                return(null);
            });
            form.ShowDialog();

            ASynch.RaiseOnModalAsyncEnd();

            if (form._error != null)
            {
                throw new ASyncException(form._error);
            }
        }
        else
        {
            try
            {
                action();
            }
            finally
            {
                ASynch.RaiseOnModalAsyncEnd();
            }
        }
    }
Ejemplo n.º 2
0
    public static T Start <T>(Func <T> action)
    {
        ASynch.RaiseOnModalAsyncStart();

        if (ASynch.IsEnabled)
        {
            var form = new AsyncForm(() => action());
            form.ShowDialog();

            ASynch.RaiseOnModalAsyncEnd();

            if (form._error != null)
            {
                throw new ASyncException(form._error);
            }

            return((T)form._result);
        }
        else
        {
            object res = null;
            try
            {
                res = action();

                ASynch.RaiseOnModalAsyncEnd();
            }
            catch
            {
                ASynch.RaiseOnModalAsyncEnd();

                throw;
            }

            return((T)res);
        }
    }