Esempio n. 1
0
        static public void ProgressFormShow(string title, string taskname, Form owner)
        {
            int ret = Interlocked.CompareExchange(ref _lck_progress_open, 1, 0);

            if (ret == 0)
            {
                #region Create progress form thread
                Thread th = new Thread(new ParameterizedThreadStart(_ProgressFormShow));
                th.Name = "Thread_ProgressForm";
                th.Start(new object[] { title, taskname, owner });
                #endregion
                #region Wait for Progress form is created.
                //DateTime started = DateTime.Now;
                //while(_progress_form == null)
                //{
                //    if (DateTime.Now.Subtract(started).TotalSeconds > 5) break;
                //    else Thread.Sleep(20);
                //}
                #endregion
            }
            else
            {
                #region Set value into progress form
                if (_progress_form != null)
                {
                    _progress_form.SetProgress(title, taskname);
                }
                #endregion
            }
        }
Esempio n. 2
0
        static private void _ProgressFormShow(object state)
        {
            try
            {
                object[] param    = (object[])state;
                string   title    = Convert.ToString(param[0]);
                string   taskname = Convert.ToString(param[1]);
                Form     owner    = (Form)param[2];

                if (_progress_form == null)
                {
                    _progress_form = new FormDictProgress();
                    _progress_form.SetProgress(title, taskname);

                    _owner_form = owner;
                    _progress_form.ShowDialog();
                }
                else
                {
                    _progress_form.SetProgress(title, taskname);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                MessageBox.Show(ex.ToString());
            }
        }