Exemplo n.º 1
0
        //**************************************************************
        // RunThread()
        //**************************************************************
        public void RunThread()
        {
            int PollRate = InitialPollInterval;

            try {
                while (true)
                {
                    Thread.Sleep(TimeSpan.FromSeconds(PollRate));
                    PollRate = PollInterval;

                    bool UpdatesAvailable = false;
                    try
                    {
                        if (AppMan.Manifest.State.Phase == UpdatePhases.Complete)
                        {
                            UpdatesAvailable = AppMan.CheckForUpdates();
                        }
                        else
                        {
                            UpdatesAvailable = false;
                        }
                    }
                    catch (Exception e)
                    {
                        //For whatever reason (perhaps the client is disconnected),
                        //we couldn't access the app on the server to check if an updated app
                        //version is available.  In this case, we want to do nothing
                        //& check to see if we can reach the app later
                        Debug.WriteLine(e.ToString());
                        UpdatesAvailable = false;
                    }
                    if (UpdatesAvailable)
                    {
                        Debug.WriteLine("APPMANAGER:  New update detected.");

                        //Download & apply the update
                        if (DownloadOnDetection)
                        {
                            AppMan.Downloader.Start();
                        }

                        //The updater runs on it's own thread, so stop the poller thread.
                        Stop();
                    }
                    else
                    {
                        Debug.WriteLine("APPMANAGER:  New update NOT detected.");
                    }
                }
            }
            catch (Exception) {
                Debug.WriteLine("APPMANAGER:  The Server Polling thread has stopped.");
            }
        }