public void Run(ReleaseConfiguration release) { _Jobs = new ConcurrentQueue <EncodingJob>(); CreateJobs <LameEncodingJob>(release); CreateJobs <FlacEncodingJob>(release); var threads = new List <Thread>(); for (int i = 0; i < Environment.ProcessorCount; i++) { var thread = new Thread(Worker); thread.Start(); } foreach (var thread in threads) { thread.Join(); } }
private void CreateJobs <JobType>(ReleaseConfiguration release) where JobType : EncodingJob, new() { int trackNumber = 1; foreach (var track in release.Tracks) { var job = new JobType(); if (!track.Number.HasValue) { track.Number = trackNumber; } job.Initialize(_Configuration, release, track); _Jobs.Enqueue(job); trackNumber++; } }
public void Initialize(GeneralConfiguration configuration, ReleaseConfiguration release, TrackConfiguration track) { Configuration = configuration; Release = release; Track = track; }