private void HandleCompilePackageListStatusComplete(Action action) { IsWorking.SetValue(false); Operation.SetValue(null); PackageListStatus.SetValue((PackageListStatus)action.Payload); }
private void HandlePackageInstallationStarted(Action action) { var args = (InstallPackageArgs)action.Payload; IsWorking.SetValue(true); Operation.SetValue("Installing " + args.PackageName + "..."); }
private async Task <bool> WorkAsync(Func <ProfileItem, Task <bool> > perform, Func <ProfileItem, bool> judge, ProfileItem targetProfile = null) { var targetProfileCopy = targetProfile ?? Profiles.FirstOrDefault(x => x.IsTarget); if (targetProfileCopy == null) { return(false); } IsWorking.TurnOn(); try { var timeoutTime = DateTime.Now.Add(_workingTimeoutDuration); if (!await perform(targetProfileCopy)) { return(false); } await Task.Delay(_workingFirstInterval); using (var cts = new CancellationTokenSource()) { while (timeoutTime > DateTime.Now) { try { await Task.WhenAll( Task.Run(async() => { await LoadProfilesAsync(false); if (judge(targetProfileCopy)) { cts.Cancel(); } }), Task.Delay(_workingSecondInterval, cts.Token)); } catch (TaskCanceledException) { } if (cts.IsCancellationRequested) { return(true); } } return(false); } } finally { IsWorking.TurnOff(); } }
private void ShowWorkingTime() { IsWorking .Select(x => new { Value = x, DateTime.Now.Ticks }) .Pairwise() .Where(x => x.OldItem.Value && !x.NewItem.Value) .Select(x => (x.NewItem.Ticks - x.OldItem.Ticks) / TimeSpan.TicksPerMillisecond) .Subscribe(x => Debug.WriteLine($"Working Time: {x}")) .AddTo(this.Subscription); }
public override int GetHashCode() { unchecked { var hashCode = RecoveriesLeft.GetHashCode(); hashCode = (hashCode * 397) ^ (Module != null ? Module.GetHashCode() : 0); hashCode = (hashCode * 397) ^ IsWorking.GetHashCode(); return(hashCode); } }
private void HandlePackageInstallationComplete(Action action) { var args = (InstallPackageArgs)action.Payload; var installedPackages = InstalledPackages.Value; installedPackages.Packages.Add(new InstalledPackage(args.PackageName, args.Version, args.GitUrl)); InstalledPackages.SetValue(installedPackages); IsWorking.SetValue(false); Operation.SetValue(null); WritePackagesJson(); }
private void HandleRemovePackageComplete(Action action) { var package = (AvailablePackage)action.Payload; IsWorking.SetValue(false); Operation.SetValue(null); var installedPackages = InstalledPackages.Value; installedPackages.Packages.RemoveAll(p => p.Name == package.Name); InstalledPackages.SetValue(installedPackages); WritePackagesJson(); }
private void HandleSwitchPackageVersionComplete(Action action) { var args = (SwitchPackageArgs)action.Payload; var installedPackages = InstalledPackages.Value; var package = installedPackages.Packages.FirstOrDefault(p => p.Name == args.Package.Name); package.Version = args.Version; InstalledPackages.SetValue(installedPackages); WritePackagesJson(); IsWorking.SetValue(false); Operation.SetValue(null); }
private async Task <bool> WorkAsync(ProfileItem targetProfile, Func <ProfileItem, Task <bool> > perform) { try { Interlocked.Increment(ref _workCount); IsWorking.TurnOn(); return(await perform.Invoke(targetProfile)); } finally { if (Interlocked.Decrement(ref _workCount) == 0) { IsWorking.TurnOff(); } } }
private void HandleCompilePackageListStatusStarted(Action action) { PackageListStatus.SetValue(null); IsWorking.SetValue(true); Operation.SetValue("Compiling status of each package"); }
private void HandleSwitchPackageVersionStarted(Action action) { IsWorking.SetValue(true); Operation.SetValue("Switching package version"); }
private void HandleRemovePackageStarted(Action action) { IsWorking.SetValue(true); Operation.SetValue("Removing " + ((AvailablePackage)action.Payload).Name + "..."); }
public override string ToString() { IsWorking?.Invoke(WorkingStatus()); return(base.ToString() + "Number Of Cows = " + NumberOfCows + '\n' + "Number Of Chickens = " + NumberOfChickens + '\n' + "Meat per month = " + MeatPerMonth() + '\n'); }
public override string ToString() { IsWorking?.Invoke(WorkingStatus()); return(base.ToString() + "Number Of Cows = " + NumberOfCows + '\n' + "Milk per day = " + MilkPerDay() + '\n'); }