public void Start() { if (string.IsNullOrEmpty(threadFile)) { throw new ArgumentNullException("Missing thread file argument"); } if (!File.Exists(threadFile)) { throw new InvalidOperationException("Thread file doesn't exists"); } for (int i = 0; i < processes.Length; i++) { ThreadProcess proc = new ThreadProcess(); proc.Port = ProcessPortBase + i; proc.Process = new Process(); proc.Process.StartInfo.FileName = threadFile; proc.Process.StartInfo.Arguments = proc.Port.ToString(); if (!proc.Process.Start()) { throw new InvalidOperationException(string.Format("Can not start thread with path \"{0}\"", threadFile)); } processes[i] = proc; } }
public ThreadServer(int threadCount, string threadFile) { processes = new ThreadProcess[threadCount]; this.threadFile = threadFile; currentProcess = 0; }