예제 #1
0
        void HandleUpdateEvent(object source, UpdateEventArgs aE)
        {
            lock (this)
            {
                switch (aE.eventType)
                {
                    case UpdateEventType.UpdateAvailable:
                        int lastState = CurrentState;
                        CurrentState = iUpdateService.UpdateAvailable ? kStateUpdateAvailable : kStateIdle;
                        if (lastState != CurrentState)
                        {
                            UpdateUserConfig("State", PropertyState());
                            if ((CurrentState == kStateUpdateAvailable) && PropertyAutoUpdate())
                            {
                                autoUpdateTimer.Change(kAutoUpdateDelay, Timeout.Infinite);
                            }
                        }
                        break;

                    case UpdateEventType.DownloadFail:
                        SetLastError("Download failed");
                        PropertiesLock();
                        SetPropertyProgress(0);
                        CurrentState = kStateUpdateAvailable;
                        PropertiesUnlock();
                        iUpdateService.Start();
                        if (PropertyAutoUpdate())
                        {
                            autoUpdateTimer.Change(kUpdateRetryInterval, Timeout.Infinite);
                        }
                        break;

                    case UpdateEventType.DownloadComplete:
                        CurrentState = kStateUpdateDownloaded;
                        UpdateUserConfig("State", PropertyState());
                        if (PropertyAutoUpdate())
                        {
                            autoUpdateTimer.Change(kAutoUpdateDelay, Timeout.Infinite);
                        }
                        break;

                    case UpdateEventType.UpdateFail:
                        SetLastError("Update failed");
                        PropertiesLock();
                        SetPropertyProgress(0);
                        CurrentState = kStateUpdateAvailable;
                        PropertiesUnlock();
                        UpdateUserConfig("State", PropertyState());
                        iUpdateService.Start();
                        if (PropertyAutoUpdate())
                        {
                            autoUpdateTimer.Change(kUpdateRetryInterval, Timeout.Infinite);
                        }
                        break;

                    case UpdateEventType.UpdateComplete:
                        CurrentState = kStateRebootNeeded;
                        UpdateUserConfig("State", PropertyState());
                        break;

                    case UpdateEventType.Progress:
                        SetPropertyProgress((uint) aE.eventData);
                        break;
                }
            }
        }
예제 #2
0
 protected void OnUpdateEvent(UpdateEventArgs aE)
 {
     if (UpdateEventHandler != null) UpdateEventHandler(this, aE);
 }