Skip to content
Enes Okullu edited this page May 8, 2024 · 10 revisions

CalculateETA has several methods for multi thread applications. All methods calculates left count of the loop, average passed time and multiply of left count and average passed time then returns it. Since it is multi thread, left count of the loop is being calculated by increasing counter each time when method is called. Substraction of counter from totalIndex is left count of the loop.

MultiThreading can be used both with static methods or creating an instance.

Creating an instance.

MultiThreading mt = new MultiThreading();
// First iteration of the loop.
// Nine iterations to finish.
// 2.000 milliseconds passed.
// Each iteration takes two seconds.
// 85 left iterations will take 85 * 1.000 ms.
CalcETA(totalIndex: 10, elapsed: 2000);

CalcETA by total elapsed time in milliseconds.

4

CalcETA(int? totalIndex, long? elapsed);
CalcETAUnsafe(int? totalIndex, long? elapsed);
CalcETA(uint? totalIndex, long? elapsed);
CalcETAUnsafe(uint? totalIndex, long? elapsed);

Returns null if any of parameter is null or returns estimated left time in milliseconds (long?)

  • int?/uint? index: Current index of loop. Index must not be zero.
  • long? totalElapsedTimeInMs: Passed time of loop in milliseconds.

CalcETA by total elapsed time in ticks.

5

CalcETA(int? totalIndex, long? elapsedTicks, long? frequency);
CalcETAUnSafe(int? totalIndex, long? elapsedTicks, long? frequency);
CalcETA(uint? totalIndex, long? elapsedTicks, long? frequency);
CalcETAUnsafe(uint? totalIndex, long? elapsedTicks, long? frequency)

Returns null if any of parameter is null or returns estimated left time in milliseconds (long?)

  • int?/uint? index: Current index of loop. Index must not be zero.
  • long? totalElapsedTicks: Passed ticks of loop.
  • long? frequency: Tick of frequency. Frequency must not be zero.

CalcETA by total elapsed time in TimeSpan.

6

CalcETA(int? totalIndex, TimeSpan? timeSpan);
CalcETAUnsafe(int? totalIndex, TimeSpan? timeSpan);
CalcETA(uint? totalIndex, TimeSpan? timeSpan);
CalcETAUnsafe(uint? totalIndex, TimeSpan? timeSpan);

Returns null if any of parameter is null or returns estimated left time in milliseconds (double?)

  • int?/uint? index: Current index of loop. Index must not be zero.
  • TimeSpan? timeSpan: Passed time of loop in TimeSpan format.

Output

  • TimeSpanETA(90000) => (TimeSpan)00:01:30
  • NumberFormatETA(90000) => "0:1:30"
  • NameETA(90000) => "1 minute(s) and 30 second(s)" (recommended for high-CPU-intense algorithm)
  • NameETABetterVisual(90000) => "1 minute and 30 seconds"(recommended for low-CPU-intense algorithm in order to offer better visual output)