Beispiel #1
0
        public void RunMultiThreadTaskLimit(int limit = 8)
        {
            foreach (var fileName in dirManager.AudioFileList)
            {
                if (taskList.Count < limit)
                {
                    AudioProcessor audioProcessor = new AudioProcessor(new AudioFile(fileName));
                    var            t = Task.Run(() => { audioProcessor.ProcessFileAsync(); });

                    taskList.Add(t);
                }
                else
                {
                    Task.WaitAny(taskList.ToArray());
                }

                for (int i = 0; i < taskList.Count; ++i)
                {
                    if (taskList[i].IsCompleted)
                    {
                        taskList[i].Dispose();
                        taskList.RemoveAt(i);
                    }
                }
            }
            Task.WaitAll(taskList.ToArray());
        }
Beispiel #2
0
        private static void RunAudioProcessor(string audioFile)
        {
            AudioProcessor audioProcessor = new AudioProcessor(new AudioFile(audioFile, mono: false));

            audioProcessor.ProcessFileAsync();
        }