Esempio n. 1
0
        public static void ShowLoading(Form parent)
        {
            int i = 0;

            loadForm = new LoadForm();

            Task.Factory.StartNew(() =>
            {
                while (loadForm != null)
                {
                    try
                    {
                        if (loadForm.IsHandleCreated)
                        {
                            loadForm.Invoke(new Action(() =>
                            {
                                i++;
                                if (loadForm != null)
                                {
                                    if (loadForm.Visible)
                                    {
                                        loadForm.SetTime(i);
                                    }
                                    else
                                    {
                                        i = 0;
                                    }
                                }
                            }));
                        }
                    }
                    catch
                    {
                        loadForm = null;
                        i        = 0;
                    }
                    Thread.Sleep(1000);
                }
            });

            Task.Factory.StartNew(() =>
            {
                Thread.Sleep(100);

                parent.Invoke(new Action(() =>
                {
                    if (loadForm != null)
                    {
                        loadForm.ShowDialog(parent);
                    }
                }));
            });
        }
Esempio n. 2
0
        public static void ShowLoading(Form parent)
        {
            _parent = parent;

            _parent.Invoke(new Action(() =>
            {
                if (_loadForm == null)
                {
                    _loadForm = new LoadForm();
                }
            }));

            _loadForm.ShowDialogWithLoopAsync(_parent, (seconds) =>
            {
                if (int.TryParse(seconds, out int os) && (os > 10 && !_loadForm.CancelLink.Visible))
                {
                    _loadForm.CancelLink.Visible = true;
                }
                _loadForm.SetTime(seconds);
            });
        }