/// <summary> /// Serves as a hash function for a particular type. /// </summary> /// <returns> /// A hash code for the current <see cref="T:System.Object"/>. /// </returns> /// <filterpriority>2</filterpriority> public override int GetHashCode() { unchecked { int result = Id; result = (result * 397) ^ (State != null ? State.GetHashCode() : 0); result = (result * 397) ^ StateEnum.GetHashCode(); result = (result * 397) ^ Project; result = (result * 397) ^ Run; result = (result * 397) ^ Clone; result = (result * 397) ^ Gen; result = (result * 397) ^ (Core != null ? Core.GetHashCode() : 0); result = (result * 397) ^ (UnitId != null ? UnitId.GetHashCode() : 0); result = (result * 397) ^ (PercentDone != null ? PercentDone.GetHashCode() : 0); result = (result * 397) ^ TotalFrames; result = (result * 397) ^ FramesDone; result = (result * 397) ^ (Assigned != null ? Assigned.GetHashCode() : 0); result = (result * 397) ^ (AssignedDateTime.HasValue ? AssignedDateTime.Value.GetHashCode() : 0); result = (result * 397) ^ (Timeout != null ? Timeout.GetHashCode() : 0); result = (result * 397) ^ (TimeoutDateTime.HasValue ? TimeoutDateTime.Value.GetHashCode() : 0); result = (result * 397) ^ (Deadline != null ? Deadline.GetHashCode() : 0); result = (result * 397) ^ (DeadlineDateTime.HasValue ? DeadlineDateTime.Value.GetHashCode() : 0); result = (result * 397) ^ (WorkServer != null ? WorkServer.GetHashCode() : 0); result = (result * 397) ^ (WorkServerIPAddress != null ? WorkServerIPAddress.GetHashCode() : 0); result = (result * 397) ^ (CollectionServer != null ? CollectionServer.GetHashCode() : 0); result = (result * 397) ^ (CollectionServerIPAddress != null ? CollectionServerIPAddress.GetHashCode() : 0); result = (result * 397) ^ (WaitingOn != null ? WaitingOn.GetHashCode() : 0); result = (result * 397) ^ Attempts; result = (result * 397) ^ (NextAttempt != null ? NextAttempt.GetHashCode() : 0); result = (result * 397) ^ (NextAttemptTimeSpan.HasValue ? NextAttemptTimeSpan.Value.GetHashCode() : 0); result = (result * 397) ^ Slot; result = (result * 397) ^ (Eta != null ? Eta.GetHashCode() : 0); result = (result * 397) ^ (EtaTimeSpan.HasValue ? EtaTimeSpan.Value.GetHashCode() : 0); result = (result * 397) ^ Ppd.GetHashCode(); result = (result * 397) ^ (Tpf != null ? Tpf.GetHashCode() : 0); result = (result * 397) ^ (TpfTimeSpan.HasValue ? TpfTimeSpan.Value.GetHashCode() : 0); result = (result * 397) ^ BaseCredit.GetHashCode(); result = (result * 397) ^ CreditEstimate.GetHashCode(); result = (result * 397) ^ (Description != null ? Description.GetHashCode() : 0); return(result); } }
public event PercentDone_EventHandler PercentDone;//事件名稱PercentDone public void LongTask(int max, int Intervals) { bool cancel = false; int i = 1; while ((i <= max)) { // Step 2; Fire Event - Invoke if (PercentDone != null) { PercentDone.Invoke(i, ref cancel); } i = (i + Intervals); if ((cancel == true)) { return; } Application.DoEvents(); } }
void _Client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) { BytesTotal = e.TotalBytesToReceive; BytesDownloaded = e.BytesReceived; if (_ProgressBar != null) { _ProgressBar.Value = (int)Math.Round(PercentDone) < 100 ? (int)Math.Round(PercentDone) : 100; } if (_Label != null) { _Label.Text = String.Format( StatusFormat, Url, File, BytesTotal / 1000, BytesDownloaded / 1000, BytesLeft / 1000, PercentDone.ToString("0.0"), KBps.ToString("0.00")); } }
private static void RunChaosGame(Variables v, FlameFunction[] Functions, double[] SumWeights, FlameState P, bool Preview, double Gamma, double LightFactor, ScriptNode Node, bool ShowStatus) { Random Gen = new Random(); FlameFunction f; double Weight; int i, j; int c = Functions.Length; for (i = 0; i < 20; i++) { Weight = Gen.NextDouble(); j = 0; while (j < c - 1 && SumWeights[j] <= Weight) { j++; } f = Functions[j]; if (!f.Operate(P, v)) { P.N = 0; break; } } if (Preview || Node.Expression.HandlesStatus) { System.DateTime Start = System.DateTime.Now; System.DateTime NextPreview = Start.AddSeconds(1); System.DateTime PrevPreview = Start; System.DateTime Temp; System.DateTime Temp2; TimeSpan TimeLeft; int NextPreviewDeciSeconds = 10; int NrIterationsPerPreview = 4096; int Pos = NrIterationsPerPreview; long NrIterations; long PrevNrIterations = 0; long NrIterationsSinceLast; double PercentDone; double IterationsPerSeconds; do { if (Pos-- <= 0) { Pos = NrIterationsPerPreview; Temp = System.DateTime.Now; if (Temp > NextPreview) { NextPreview = Temp.AddSeconds(NextPreviewDeciSeconds * 0.1); if (NextPreviewDeciSeconds < 50) { NextPreviewDeciSeconds++; } if (Preview) { Node.Expression.Preview(new GraphBitmap(P.RenderBitmapHsl(Gamma, LightFactor, true, SKColors.Black))); Temp2 = System.DateTime.Now; double d = (Temp2 - Temp).TotalSeconds; double d2 = (Temp - PrevPreview).TotalSeconds; if (d / d2 > 0.1) { NrIterationsPerPreview <<= 1; if (NrIterationsPerPreview < 0) { NrIterationsPerPreview = int.MaxValue; } } } NrIterations = P.N0 - P.N; NrIterationsSinceLast = NrIterations - PrevNrIterations; IterationsPerSeconds = NrIterationsSinceLast / (Temp - PrevPreview).TotalSeconds; PercentDone = (100 * (1.0 - ((double)P.N) / P.N0)); TimeLeft = new TimeSpan((long)((Temp - Start).Ticks * 100 / PercentDone)); Node.Expression.Status(P.N.ToString() + " iterations left, " + NrIterations.ToString() + " iterations done, " + IterationsPerSeconds.ToString("F0") + " iterations/s, " + PercentDone.ToString("F1") + "% done, Time Left: " + TimeLeft.ToString() + "."); PrevNrIterations = NrIterations; PrevPreview = Temp; } } Weight = Gen.NextDouble(); j = 0; while (j < c - 1 && SumWeights[j] <= Weight) { j++; } f = Functions[j]; if (!f.Operate(P, v)) { break; } }while (P.IncHistogram()); Node.Expression.Status(string.Empty); } else { do { Weight = Gen.NextDouble(); j = 0; while (j < c - 1 && SumWeights[j] <= Weight) { j++; } f = Functions[j]; if (!f.Operate(P, v)) { break; } }while (P.IncHistogram()); } }