Beispiel #1
0
        public void DoWork(ProgressStart progressStart)
        {
            if (ConnectionUtil.Instance.IsTimeOutApp)
            {
                return;
            }

            if (!isHandleCreated)
            {
                this.Value = 0;

                IsCompleted = false;

                var progressWorker = new Thread(CastDelegate <ThreadStart>(progressStart));

                //Debug.Print("{0} Thread Id: {1} create new thread {2} to async execute {3}...", DateTime.Now, Thread.CurrentThread.ManagedThreadId, progressWorker.ManagedThreadId, progressStart.Method.Name);

                progressWorker.Start();

                if (Environment.UserInteractive && !Visible)
                {
                    ShowDialog();
                }
                else
                {
                    progressWorker.Join();

                    Thread.CurrentThread.Join(3000);
                }
            }
            else
            {
                if (checkPending(progressStart))
                {
                    return;
                }

                PushStatus();

                Value = 0;

                IsCompleted = false;

                var progressWorker = new Thread(CastDelegate <ThreadStart>(progressStart));

                //Debug.Print("{0} Thread Id: {1} create new thread {2} to async execute {3}...", DateTime.Now, Thread.CurrentThread.ManagedThreadId, progressWorker.ManagedThreadId, progressStart.Method.Name);

                progressWorker.Start();

                progressWorker.Join();

                Thread.CurrentThread.Join(3000);
            }
        }
        /// <summary>
        /// Called when progress action starts.
        /// </summary>
        protected virtual void OnStart()
        {
            if (_isActive)
            {
                throw new InvalidOperationException("Already started.");
            }

            _isActive = true;
            _progress = 0;
            _infoText = string.Empty;
            ProgressStart?.Invoke(this);
            ProgressChanged?.Invoke(this);
        }
Beispiel #3
0
        public void DoWork(IWin32Window owner, ProgressStart progressStart)
        {
            if (ConnectionUtil.Instance.IsTimeOutApp)
            {
                return;
            }
            this.Value  = 0;
            IsCompleted = false;
            var progressWorker = new Thread(CastDelegate <ThreadStart>(progressStart));

            progressWorker.Start();
            if (Environment.UserInteractive)
            {
                this.ShowDialog(owner);
            }
            else
            {
                progressWorker.Join();
                Thread.CurrentThread.Join(2500);
            }
        }
Beispiel #4
0
        private bool checkPending(ProgressStart progressStart)
        {
            if (progressStart.Method.Name == "RetryConnect")
            {
                if (!IsRetryingConnect)
                {
                    IsRetryingConnect = true;
                }
                else
                {
                    while (IsRetryingConnect)
                    {
                        Thread.CurrentThread.Join(1000);
                    }

                    return(true);
                }
            }

            return(false);
        }
Beispiel #5
0
 protected virtual void OnProgressStart(EventArgs args)
 {
     ProgressStart?.Invoke(this, args);
 }