private void Work() { sampleSource.SetPosition(BeginSample); long pos = beginSample; while (!pleaseTerminate && (endSample < 0 || pos < endSample)) { double[] chunk = sampleSource.GetChunk(chunkSize); if (chunk.LongLength == 0) { chunk = null; } if (SamplesRetrieved != null) { SamplesRetrieved(this, chunk, pos); } if (chunk == null) { break; } pos += chunk.LongLength; } if (SamplesRetrievingDone != null) { SamplesRetrievingDone(this, new EventArgs()); } }