private static void RunProducer(object obj) { int delay; StreamReader input = File.OpenText(_inputFileInfo.FullName); try { delay = (int)obj; } catch (InvalidCastException) { delay = 5000; } while (_runThread) { string currentLine = input.ReadLine(); if (currentLine != null) { List <string> lineSplit = new List <string>(currentLine.Split(',')); if (lineSplit.Count != 2) { continue; } string lineType = lineSplit[0].ToLower(); ConsumerType currentType = ConsumerType.CONSOLE; if (lineType.Equals("console")) { currentType = ConsumerType.CONSOLE; } else if (lineType.Equals("file")) { currentType = ConsumerType.FILE; } else { continue; } DataItem currentItem = new DataItem(currentType, lineSplit[1]); _dataQueue.AddItem(currentItem); } Thread.Sleep(delay); } Thread.Sleep(0); }