wyDay.Controls.AutomaticUpdaterBackend.AppLoaded C# (CSharp) Method

AppLoaded() public method

The function that must be called when your app has loaded.
public AppLoaded ( ) : void
return void
        public void AppLoaded()
        {
            if (AutoUpdaterInfo == null)
                throw new FailedToInitializeException();

            // if we want to kill ourself, then don't bother checking for updates
            if (ClosingForInstall)
                return;

            // get the current update step from the info file
            m_UpdateStepOn = AutoUpdaterInfo.UpdateStepOn;

            if (UpdateStepOn != UpdateStepOn.Nothing)
            {
                version = AutoUpdaterInfo.UpdateVersion;
                changes = AutoUpdaterInfo.ChangesInLatestVersion;
                changesAreRTF = AutoUpdaterInfo.ChangesIsRTF;

                switch (UpdateStepOn)
                {
                    case UpdateStepOn.UpdateAvailable:
                        if (internalUpdateType == UpdateType.CheckAndDownload || internalUpdateType == UpdateType.Automatic)
                            DownloadUpdate(); // begin downloading the update
                        else
                            UpdateReady();

                        break;

                    case UpdateStepOn.UpdateReadyToInstall:
                        UpdateReadyToInstall();
                        break;

                    case UpdateStepOn.UpdateDownloaded:

                        if (internalUpdateType == UpdateType.Automatic)
                            ExtractUpdate(); // begin extraction
                        else
                            UpdateReadyToExtract();

                        break;
                }
            }
            else // UpdateStepOn == UpdateStepOn.Nothing
            {
                switch (AutoUpdaterInfo.AutoUpdaterStatus)
                {
                    case AutoUpdaterStatus.UpdateSucceeded:

                        // set the version & changes
                        version = AutoUpdaterInfo.UpdateVersion;
                        changes = AutoUpdaterInfo.ChangesInLatestVersion;
                        changesAreRTF = AutoUpdaterInfo.ChangesIsRTF;

                        if (UpdateSuccessful != null)
                            UpdateSuccessful(this, new SuccessArgs { Version = version });

                        break;
                    case AutoUpdaterStatus.UpdateFailed:

                        if (UpdateFailed != null)
                            UpdateFailed(this, new FailArgs { ErrorTitle = AutoUpdaterInfo.ErrorTitle, ErrorMessage = AutoUpdaterInfo.ErrorMessage });

                        break;
                }

                // clear the changes and resave
                AutoUpdaterInfo.ClearSuccessError();
                AutoUpdaterInfo.Save();
            }
        }

Usage Example

Exemplo n.º 1
0
        static void Main(string[] args)
        {
            auBackend = new AutomaticUpdaterBackend
                            {
                                //TODO: set a unique string. For instance, "appname-companyname"
                                GUID = "a-string-that-uniquely-IDs-your-app",

                                // With UpdateType set to Automatic, you're still in charge of
                                // checking for updates, but the AutomaticUpdaterBackend
                                // continues with the downloading and extracting automatically.
                                UpdateType = UpdateType.Automatic
                            };

            auBackend.ReadyToBeInstalled += auBackend_ReadyToBeInstalled;
            auBackend.UpdateSuccessful += auBackend_UpdateSuccessful;

            //TODO: use the failed events for logging & error reporting:
            // CheckingFailed, DownloadingFailed, ExtractingFailed, UpdateFailed

            // the functions to be called after all events have been set.
            auBackend.Initialize();
            auBackend.AppLoaded();

            // sees if you checked in the last 10 days, if not it rechecks
            CheckEvery10Days();

            // Blocks until "resetEvent.Set()" on another thread
            resetEvent.WaitOne();
        }
All Usage Examples Of wyDay.Controls.AutomaticUpdaterBackend::AppLoaded