コード例 #1
0
        /// <summary>
        /// Call this static method to start a time-consuming operation that DOES NOT involve user interface (the operation may NOT access form controls).
        /// For example, you may call this method to execute an entity adapter method that takes several seconds to complete.
        /// The user is notified through "Please wait..." window.
        /// </summary>
        public static void StartNonUIOperation(LongOperationEventHandler operation)
        {
            LongOperation dlg = new LongOperation(null, operation);

            dlg.ShowDialog();
            if (dlg.longOperationException != null)
            {
                throw new Exception(null, dlg.longOperationException);
            }
        }
コード例 #2
0
        /// <summary>
        /// Call this static method to start a time-consuming operation involving user interface (the operation may access form controls). The user is notified through "Please wait..." window.
        /// </summary>
        public static void StartUIOperation(Control parent, LongOperationEventHandler operation)
        {
            LongOperation dlg = new LongOperation(parent, operation);

            dlg.ShowDialog();
            if (dlg.longOperationException != null)
            {
                throw dlg.longOperationException;
            }
        }
コード例 #3
0
        /// <summary>
        /// Call this static method to start a time-consuming operation.
        /// The user is notified through a hourglass icon.
        /// </summary>
        public static void StartUIOperationWithHourglass(Control ctrl, LongOperationEventHandler operation)
        {
            Cursor oldCursor = ctrl.Cursor;

            ctrl.Cursor = Cursors.WaitCursor;
            try
            {
                operation();
            }
            finally
            {
                ctrl.Cursor = oldCursor;
            }
        }
コード例 #4
0
 public LongOperation(Control parent, LongOperationEventHandler operation)
 {
     InitializeComponent();
     this.operation = operation;
     this.parent    = parent;
 }