public override bool Equals(object obj) { if (obj is VideoRenderOptions options && Type == options.Type && DxFailureCounter == options.DxFailureCounter && MainWindowHandle.Equals(options.MainWindowHandle) && EnableObjectTracking == options.EnableObjectTracking) { if (Type == VideoRenderType.HardwareSpecific) { return(Adapter == options.Adapter); } else { return(true); } } return(false); }
public override string GetTextMessage() { return(ID.ToString() + msgDelimiter + (LogFileName ?? String.Empty) + msgDelimiter + WhenWasActive.ToString("s") + msgDelimiter + MainWindowHandle.ToString()); }
public int Run(string[] args) { // Start self update downloadThreads.Add(RunThread(SelfUpdate)); DebugStep("SelfUpdate launched"); // Find locally installed package var installedPackage = FindLatestInstalledPackage(store.Manager.LocalRepository); DebugStep("Find installed package"); // Do we have a package in the cache? var cachePackage = FindLatestInstalledPackage(MachineCache.Default); DebugStep("Find cache package"); // If a package is installed if (installedPackage != null) { if (cachePackage != null && cachePackage.Version > installedPackage.Version) { var processCount = GetProcessCount(); bool isSafeToUpdate = processCount <= 1; // If we are safe to update, install the new package if (isSafeToUpdate) { IsDownloading = true; Info("Preparing installer for new {0} version {1}", mainPackage, cachePackage.Version); PackageUpdate(installedPackage, false); IsDownloading = false; DebugStep("Update package"); } else { ShowInformationDialog( string.Format("Cannot update {0} as there are [{1}] instances currently running.\n\nClose all your applications and restart", mainPackage, processCount)); } } else { DebugStep("Start download package in cache"); var localPackage = installedPackage; downloadThreads.Add(RunThread(() => PackageUpdate(localPackage, true))); } } else { if (store.CheckSource()) { //store.Manager.InstallPackage(mainPackage); IsDownloading = true; Info("Preparing installer for {0}", mainPackage); store.InstallPackage(mainPackage, null); IsDownloading = false; DebugStep("Package installed"); } else { ShowErrorDialog("Download server not available. Please try again later"); return(1); } } installedPackage = FindLatestInstalledPackage(store.Manager.LocalRepository); if (installedPackage == null) { ShowErrorDialog("No package installed"); return(1); } // Load the assembly and call the default entry point: var fullExePath = GetMainExecutable(installedPackage); Environment.CurrentDirectory = Path.GetDirectoryName(fullExePath); var appDomainSetup = new AppDomainSetup { ApplicationBase = Path.GetDirectoryName(fullExePath) }; var newAppDomain = AppDomain.CreateDomain("LauncherAppDomain", null, appDomainSetup); DebugStep("Run executable"); OnLoading(new LoadingEventArgs(installedPackage.Id, installedPackage.Version.ToString())); var newArgList = new List <string> { "/LauncherWindowHandle", MainWindowHandle.ToInt64().ToString(CultureInfo.InvariantCulture) }; newArgList.AddRange(args); try { return(newAppDomain.ExecuteAssembly(fullExePath, newArgList.ToArray())); } finally { // Important!: Force back current directory to this application as previous ExecuteAssembly is changing it Environment.CurrentDirectory = Path.GetDirectoryName(typeof(LauncherApp).Assembly.Location); // Note: The AppDomain.Unload method can block indefinitely when a crash occurs in the UI //try //{ // AppDomain.Unload(newAppDomain); //} //catch (Exception) //{ //} } }