Exemple #1
0
        public bool DoDownloadsFg(bool showProgress, bool showMsgBox, ICollection <SeriesSpecifier> shows)
        {
            if (TVSettings.Instance.OfflineMode)
            {
                return(true); // don't do internet in offline mode!
            }

            Logger.Info("Doing downloads in the foreground...");

            StartBgDownloadThread(true, shows, showMsgBox);

            const int DELAY_STEP = 100;
            int       count      = 1000 / DELAY_STEP; // one second

            while (count-- > 0 && !DownloadDone)
            {
                Thread.Sleep(DELAY_STEP);
            }

            if (!DownloadDone && showProgress) // downloading still going on, so time to show the dialog if we're not in /hide mode
            {
                DownloadProgress dp = new DownloadProgress(this);
                dp.ShowDialog();
                dp.Update();
            }

            WaitForBgDownloadDone();

            if (!downloadOk)
            {
                Logger.Warn(LocalCache.Instance.LastErrorMessage);
                if (showErrorMsgBox)
                {
                    CannotConnectForm ccform   = new CannotConnectForm("Error while downloading", LocalCache.Instance.LastErrorMessage);
                    DialogResult      ccresult = ccform.ShowDialog();
                    if (ccresult == DialogResult.Abort)
                    {
                        TVSettings.Instance.OfflineMode = true;
                    }
                }

                LocalCache.Instance.LastErrorMessage = "";
            }

            return(downloadOk);
        }