private string MakeFinalFileName(int batchIndex, Batch batch, GeneratorParams parameters)
		{
			if (string.IsNullOrWhiteSpace(batch.FileNameFormat))
				throw new ArgumentException("Invalid batch file name format.");
			return batch.FileNameFormat
				.Replace("{i}", batchIndex.ToString())
				.Replace("{b}", parameters.BurstTimeMean.ToString())
				.Replace("{p}", parameters.PriorityMean.ToString())
				.Replace("{m}", parameters.MemoryMean.ToString());
		}
 public Batch CreateBatch(int randSeed, GeneratorParams parameters)
 {
     var rand = new Random(randSeed);
     var processeDescs = new ProcessDesc[parameters.ProcessCount];
     for (int j = 0; j < parameters.ProcessCount; j++)
     {
         processeDescs[j] = new ProcessDesc(
             cpuBurstTime: Math.Max(0, rand.NextNormal(parameters.BurstTimeMean, parameters.BurstTimeStDev)),
             delay: Math.Max(0, rand.Next(parameters.DelayMin, parameters.DelayMax)),
             priority: Math.Max(0, rand.NextNormal(parameters.PriorityMean, parameters.PriorityStDev)),
             memory: Math.Max(0, rand.NextNormal(parameters.MemoryMean, parameters.MemoryStDev)));
     }
     return new Batch(parameters.FileNameFormat, processeDescs);
 }
		public async Task<bool> TryGenerate(GeneratorParams parameters)
		{
			var batches = new Batch[parameters.BatchCount];

			await Task.Run(() =>
			{
				Parallel.For(0, parameters.BatchCount, i =>
				{
					batches[i] = batchCreator.CreateBatch(i.GetHashCode(), parameters);
				});
			});

			var batchesWithFileNames = batches.Select((batch, batchIndex) => new
			{
				Batch = batch,
				FilePath = MakeFinalFileName(batchIndex, batch, parameters)
			});

			return (await Task.WhenAll(batchesWithFileNames.Select(async item => new
			{
				Result = await batchWriter.TryWriteBatchFile(item.FilePath, item.Batch),
				Path = item.FilePath
			}))).All(item => item.Result);
		}
		private bool TryParseInputs(out GeneratorParams parameters)
		{
			parameters = new GeneratorParams();

			if (!float.TryParse(burstTimeMeanTextBox.Text, out parameters.BurstTimeMean))
			{
				MessageBox.Show("Invalid burst time mean value.", "Invalid Input", MessageBoxButtons.OK);
				return false;
			}

			if (!float.TryParse(burstTimeStDevTextBox.Text, out parameters.BurstTimeStDev))
			{
				MessageBox.Show("Invalid burst time standard deviation value.", "Invalid Input", MessageBoxButtons.OK);
				return false;
			}

			if (!int.TryParse(delayMinTextBox.Text, out parameters.DelayMin))
			{
				MessageBox.Show("Invalid delay min value.", "Invalid Input", MessageBoxButtons.OK);
				return false;
			}

			if (!int.TryParse(delayMaxTextBox.Text, out parameters.DelayMax))
			{
				MessageBox.Show("Invalid delay max value.", "Invalid Input", MessageBoxButtons.OK);
				return false;
			}

			if (parameters.DelayMin > parameters.DelayMax)
			{
				MessageBox.Show("Minimum delay must be less than or equal to maximum delay.", "Invalid Input", MessageBoxButtons.OK);
				return false;
			}

			if (!float.TryParse(priorityMeanTextBox.Text, out parameters.PriorityMean))
			{
				MessageBox.Show("Invalid priority mean value.", "Invalid Input", MessageBoxButtons.OK);
				return false;
			}

			if (!float.TryParse(priorityStDevTextBox.Text, out parameters.PriorityStDev))
			{
				MessageBox.Show("Invalid priority standard deviation value.", "Invalid Input", MessageBoxButtons.OK);
				return false;
			}

			if (!float.TryParse(memoryMeanTextBox.Text, out parameters.MemoryMean))
			{
				MessageBox.Show("Invalid memory mean value.", "Invalid Input", MessageBoxButtons.OK);
				return false;
			}

			if (!float.TryParse(memoryStDevTextBox.Text, out parameters.MemoryStDev))
			{
				MessageBox.Show("Invalid memory standard deviation value.", "Invalid Input", MessageBoxButtons.OK);
				return false;
			}

			if (!float.TryParse(burstTimeMeanTextBox.Text, out parameters.BurstTimeMean))
			{
				MessageBox.Show("Invalid burst time mean value.", "Invalid Input", MessageBoxButtons.OK);
				return false;
			}

			if (string.IsNullOrWhiteSpace(fileNameFormatTextBox.Text))
			{
				MessageBox.Show("Invalid file name format value.", "Invalid Input", MessageBoxButtons.OK);
				return false;
			}
			parameters.FileNameFormat = fileNameFormatTextBox.Text;

			if (!int.TryParse(processCountTextBox.Text, out parameters.ProcessCount))
			{
				MessageBox.Show("Invalid process per batch value.", "Invalid Input", MessageBoxButtons.OK);
				return false;
			}

			if (!int.TryParse(batchCountTextBox.Text, out parameters.BatchCount))
			{
				MessageBox.Show("Invalid batch count value.", "Invalid Input", MessageBoxButtons.OK);
				return false;
			}

			return true;
		}