static void SingleThread() { using (StreamWriter sw = new StreamWriter(file1)) { PersonProvider provider = new PersonProvider(); Person[] persons = provider.GetPersons(1, portionSize); while (persons.Length > 0) { for (int i = 0; i < persons.Length; i++) { sw.WriteLine(persons[i]); } Person lastP = persons[persons.Length - 1]; persons = provider.GetPersons(lastP.Id + 1, portionSize); } } }
static void GetPersons() { PersonProvider provider = new PersonProvider(); Person[] persons = provider.GetPersons(1, portionSize); while (persons.Length > 0) { lock (_lockObject) { if (_pQueue.Count < _maxQueueSize) { _pQueue.Enqueue(persons); Person lastP = persons[persons.Length - 1]; persons = provider.GetPersons(lastP.Id + 1, portionSize); } } } lock (_lockObject) { _personsReadEnded = true; } }
private static void RunPersonsDemo(AppView view) { var persons = PersonProvider.GetPersons(); view.Show(persons); }