Skip to content

Commit

Permalink
Changed method for tracking instance IDs
Browse files Browse the repository at this point in the history
The ObjectIDGenerator provided by .NET suffered from System.IndexOutOfRangeException: Index was outside the bounds of the array.
  at System.Runtime.Serialization.ObjectIDGenerator.GetId exceptions.

Reverted to a simpler idea. Continuation of 75bc53b
  • Loading branch information
atruskie committed May 1, 2018
1 parent 75bc53b commit 2ffac42
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/Acoustics.Shared/ProcessRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Acoustics.Shared
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Fasterflect;
using log4net;
Expand All @@ -22,15 +23,15 @@ namespace Acoustics.Shared
public class ProcessRunner : IDisposable
{
private static readonly ILog Log = LogManager.GetLogger(nameof(ProcessRunner));
private static readonly ObjectIDGenerator InstanceTracker = new ObjectIDGenerator();
private static long instanceCounter = 0;

private readonly long instanceId = Interlocked.Increment(ref instanceCounter);
private StringBuilder standardOutput;
private StringBuilder errorOutput;
private List<string> failedRuns;
private Process process;
private bool exitCodeSet;
private int exitCode;
private long instanceId;

/// <summary>
/// Initializes a new instance of the <see cref="ProcessRunner"/> class.
Expand All @@ -57,10 +58,6 @@ public ProcessRunner(string filePath)

this.WaitForExit = true;
this.MaxRetries = 0;
lock (this)
{
this.instanceId = InstanceTracker.GetId(this, out var _);
}
}

public int ExitCode
Expand Down

0 comments on commit 2ffac42

Please sign in to comment.