public static void Check(UpdateCompleteDelegate callback = null, ReleaseStream stream = ReleaseStream.Stable40, ThreadPriority priority = ThreadPriority.Normal) { lock (UpdateLock) { if (updateThread != null) { return; } ReleaseStream = stream; completeCallback = callback; setCallbackStatus(UpdateStates.Checking); updateThread = new Thread(() => { try { Log(); Log(@"Beginning update thread"); Log(@"Stream: " + ReleaseStream.ToString()); Log(); UpdateStates state = doUpdate(); Log(); Log(@"Ending update thread with result: " + state); Log(); setCallbackStatus(state); } catch (ThreadAbortException) { setCallbackStatus(UpdateStates.NoUpdate); } catch (Exception e) { Log(@"Serious error occurred in update thread: " + e.ToString()); Log(@"Returning NoUpdate state to caller"); setCallbackStatus(UpdateStates.EmergencyFallback); } completeCallback = null; updateThread = null; }); updateThread.IsBackground = true; updateThread.Priority = priority; updateThread.Start(); } }
// Token: 0x060015CB RID: 5579 // RVA: 0x0006FE40 File Offset: 0x0006E040 public static void Check(Delegate26 delegate26_1, ReleaseStream releaseStream_1, ThreadPriority threadPriority_0) { lock (Class214.object_0) { if (Class214.thread_0 == null) { Class214.releaseStream_0 = releaseStream_1; Class214.delegate26_0 = delegate26_1; Class214.smethod_2(Enum32.const_1); if (Class214.threadStart_0 == null) { Class214.threadStart_0 = new ThreadStart(Class214.smethod_10); } Class214.thread_0 = new Thread(Class214.threadStart_0); Class214.thread_0.IsBackground = true; Class214.thread_0.Priority = threadPriority_0; Class214.thread_0.Start(); } } }
void update(object sender, DoWorkEventArgs e) { init(); try { #if Public ReleaseStream stream = ReleaseStream.Stable40; #else ReleaseStream stream = ReleaseStream.CuttingEdge; #endif bool hasFramework = File.Exists(@"OpenTK.dll"); List <string> files = new List <string>(Directory.GetFiles(Environment.CurrentDirectory)); bool useCurrentDirectory = File.Exists(@"osu!.cfg") || files.Count == 1; if (!hasFramework) { retry_with_default: if (!useCurrentDirectory) { installPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"osu!"); label.Click += chooseFolder; int seconds = 10; while (seconds > 0) { setText(string.Format(LocalisationManager.GetString(OsuString.Maintenance_InstallationPath) + '\n' + LocalisationManager.GetString(OsuString.Maintenance_InstallationPath2), installPath, seconds), true); Thread.Sleep(1000); seconds--; while (installPath == null) { Thread.Sleep(100); } } label.Click -= chooseFolder; } retry: if (installPath != Environment.CurrentDirectory) { string installExecutable = Path.Combine(installPath, @"osu!.exe"); try { if (!Directory.Exists(installPath)) { Directory.CreateDirectory(installPath); } try { File.Delete(installExecutable); } catch (IOException) { //ignore IOExceptions for now } byte[] executable = File.ReadAllBytes(OsuMain.FullPath); using (FileStream fs = File.Create(installExecutable)) fs.Write(executable, 0, executable.Length); } catch (UnauthorizedAccessException) { if (!OsuMain.IsElevated) { if (OsuMain.Elevate(@"-allowuserwrites " + installPath, true)) { goto retry; } else { //error occurred while elevating. try again using the default path. goto retry_with_default; } } } Process.Start(installExecutable); OsuMain.ExitImmediately(); } } try { if (hasFramework) { stream = ConfigManager.sReleaseStream.Value; } } catch (Exception ex) { OsuMain.Repair(true, ex); } setText(string.Empty); tryAgain: setProgress(); if (hasFramework) //force a complete check. { ConfigManager.ResetHashes(); } CommonUpdater.Check(delegate(UpdateStates s) { }, stream); while (true) { switch (CommonUpdater.State) { case UpdateStates.Checking: setText(CommonUpdater.GetStatusString(), detailedTextImportant); setProgress(); Thread.Sleep(20); continue; case UpdateStates.Updating: setText(CommonUpdater.GetStatusString()); setProgress(CommonUpdater.Percentage); Thread.Sleep(20); continue; case UpdateStates.Completed: case UpdateStates.NeedsRestart: setText(LocalisationManager.GetString(OsuString.CommonUpdater_Updated)); break; case UpdateStates.NoUpdate: setText(LocalisationManager.GetString(OsuString.CommonUpdater_Updated), true); Thread.Sleep(1000); break; case UpdateStates.Error: CommonUpdater.Reset(); setProgress(); setText(LocalisationManager.GetString(OsuString.Maintenance_ErrorOccurred), true); Thread.Sleep(5000); goto tryAgain; default: break; } break; } if (!OsuMain.IsWine && !hasFramework) { //create desktop/start menu shortcuts only once per install ShellLinkHelper.Create(icon_path_desktop, Path.Combine(Environment.CurrentDirectory, @"osu!.exe"), @"osu!"); ShellLinkHelper.Create(icon_path_startmenu, Path.Combine(Environment.CurrentDirectory, @"osu!.exe"), @"osu!"); } instance.Dispose(); DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show(@"Error occured (please report this!):\n\n" + ex.ToString()); } }