void StateMsgUpdate() { do { LinkedListNode <AutoUpdateMsgNode> node; lock (m_Lock) { node = m_StateMsgList.First; if (node == null) { break; } m_StateMsgList.RemoveFirst(); } if (node.Value.autoUpdateState >= 0) { Release(); AutoUpdateState state = (AutoUpdateState)node.Value.autoUpdateState; if (m_StateMgr.ChangeState(state)) { CallStateChanged(state); } } else if (node.Value.errType >= 0) { AutoUpdateErrorType errType = (AutoUpdateErrorType)node.Value.errType; if (OnError != null) { OnError(errType, node.Value.errStatus); } } } while (true); }
void SetLastUpdateCheckInfo(UpdateInfoFileContent updateInfoFileContent) { LastUpdateCheckInfo info = null; if (updateInfoFileContent.LastCheckTimestamp.HasValue) { info = new LastUpdateCheckInfo() { When = updateInfoFileContent.LastCheckTimestamp.Value, ErrorMessage = updateInfoFileContent.LastCheckError } } ; lock (sync) { lastUpdateResult = info; } FireChangedEvent(); } void SetState(AutoUpdateState state) { lock (sync) { if (this.state == state) { return; } this.state = state; } trace.Info("autoupdater state -> {0}", state); FireChangedEvent(); }
void StateChanged(AutoUpdateState state) { Debug.LogFormat("AutoUpdate ChangeState: {0:D}", (int)state); if (state == AutoUpdateState.auEnd) { // 進入遊戲 Debug.Log("Enter Game!!!"); } else if (state == AutoUpdateState.auFinished) { // 下載完成 Debug.Log("Res Update Finished!!!"); float delta = Time.realtimeSinceStartup - m_StartTimer; Debug.LogFormat("下载耗时:{0}", delta.ToString()); if (m_LbUseDownTime != null) { m_LbUseDownTime.text = delta.ToString("F2"); } ResourceMgr.Instance.AutoUpdateClear(); ResourceMgr.Instance.LoadConfigs(OnResLoad); } }
private void CallStateChanged(AutoUpdateState state) { if (OnStateChanged != null) { OnStateChanged(state); } }
internal void ChangeState(AutoUpdateState state) { Release(); lock (m_Lock) { m_StateMgr.ChangeState(state); } }
private void AddChgState(AutoUpdateState state) { AutoUpdateMsgNode node = AutoUpdateMsgNode.Create(); node.autoUpdateState = (int)state; lock (m_Lock) { m_StateMsgList.AddLast(node); } }
void SetState(AutoUpdateState value) { lock (sync) { if (this.state == value) { return; } this.state = value; } trace.Info("autoupdater state -> {0}", value); FireChangedEvent(); }
void StateChanged(AutoUpdateState state) { Debug.LogFormat("AutoUpdate ChangeState: {0:D}", (int)state); if (state == AutoUpdateState.auEnd) { // 進入遊戲 Debug.Log("Enter Game!!!"); } else if (state == AutoUpdateState.auFinished) { // 下載完成 Debug.Log("Res Update Finished!!!"); ResourceMgr.Instance.AutoUpdateClear(); ResourceMgr.Instance.LoadConfigs(OnResLoad); } }
public AutoUpdater( MultiInstance.IInstancesCounter mutualExecutionCounter, IUpdateDownloader updateDownloader, ITempFilesManager tempFiles, IShutdown shutdown, IInvokeSynchronization eventInvoker, IFirstStartDetector firstStartDetector, Telemetry.ITelemetryCollector telemetry, Persistence.IStorageManager storage ) { this.mutualExecutionCounter = mutualExecutionCounter; this.updateDownloader = updateDownloader; this.tempFiles = tempFiles; this.manualCheckRequested = new TaskCompletionSource <int>(); this.firstStartDetector = firstStartDetector; this.managedAssembliesPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); this.updateInfoFilePath = Path.Combine(managedAssembliesPath, updateInfoFileName); this.installationDir = Path.GetFullPath( Path.Combine(managedAssembliesPath, installationPathRootRelativeToManagedAssembliesLocation)); this.eventInvoker = eventInvoker; this.telemetry = telemetry; this.storage = storage; shutdown.Cleanup += (s, e) => ((IDisposable)this).Dispose(); this.updatesStorageEntry = storage.GetEntry("updates"); bool isFirstInstance = mutualExecutionCounter.IsPrimaryInstance; bool isDownloaderConfigured = updateDownloader.IsDownloaderConfigured; if (!isDownloaderConfigured) { trace.Info("autoupdater is disabled - update downloader not configured"); isActiveAutoUpdaterInstance = false; state = AutoUpdateState.Disabled; } else if (!isFirstInstance) { trace.Info("autoupdater is deactivated - not a first instance of logjoint"); isActiveAutoUpdaterInstance = false; state = AutoUpdateState.Inactive; } else { trace.Info("autoupdater is enabled"); isActiveAutoUpdaterInstance = true; state = AutoUpdateState.Idle; workerCancellation = new CancellationTokenSource(); workerCancellationToken = workerCancellation.Token; workerCancellationTask = new TaskCompletionSource <int>(); worker = TaskUtils.StartInThreadPoolTaskScheduler(Worker); } }
public void ChangeState(AutoUpdateState state) { //Release (); AddChgState(state); }
public AutoUpdater( IFactory factory, MultiInstance.IInstancesCounter mutualExecutionCounter, IShutdown shutdown, ISynchronizationContext eventInvoker, Telemetry.ITelemetryCollector telemetry, Persistence.IStorageManager storage, ITraceSourceFactory traceSourceFactory, Extensibility.IPluginsManagerInternal pluginsManager, IChangeNotification changeNotification ) { this.updateDownloader = factory.CreateAppUpdateDownloader(); this.checkRequested = new TaskCompletionSource <int>(); this.factory = factory; this.pluginsManager = pluginsManager; this.trace = traceSourceFactory.CreateTraceSource("AutoUpdater"); var entryAssemblyLocation = Assembly.GetEntryAssembly()?.Location; if (entryAssemblyLocation != null) { this.managedAssembliesPath = Path.GetDirectoryName(entryAssemblyLocation); this.updateInfoFilePath = Path.Combine(managedAssembliesPath, Constants.updateInfoFileName); this.installationDir = Path.GetFullPath( Path.Combine(managedAssembliesPath, Constants.installationPathRootRelativeToManagedAssembliesLocation)); } this.eventInvoker = eventInvoker; this.telemetry = telemetry; this.storage = storage; shutdown.Cleanup += (s, e) => ((IDisposable)this).Dispose(); this.updatesStorageEntry = storage.GetEntry("updates"); bool isFirstInstance = mutualExecutionCounter.IsPrimaryInstance; bool isDownloaderConfigured = updateDownloader.IsDownloaderConfigured; if (entryAssemblyLocation == null) { trace.Info("autoupdater is disabled - no entry assembly"); isActiveAutoUpdaterInstance = false; state = AutoUpdateState.Disabled; } else if (!isDownloaderConfigured) { trace.Info("autoupdater is disabled - update downloader not configured"); isActiveAutoUpdaterInstance = false; state = AutoUpdateState.Disabled; } else if (!isFirstInstance) { trace.Info("autoupdater is deactivated - not a first instance of logjoint"); isActiveAutoUpdaterInstance = false; state = AutoUpdateState.Inactive; } else { trace.Info("autoupdater is enabled"); isActiveAutoUpdaterInstance = true; state = AutoUpdateState.Idle; workerCancellation = new CancellationTokenSource(); workerCancellationToken = workerCancellation.Token; workerCancellationTask = new TaskCompletionSource <int>(); changeListenerSubscription = changeNotification.CreateSubscription(Updaters.Create( () => pluginsManager.InstallationRequests, (_, prev) => { if (prev != null) { checkRequested.TrySetResult(1); } } )); worker = TaskUtils.StartInThreadPoolTaskScheduler(Worker); } }
public void CheckUpdate() { State = GetState(); }