I'm fetching more than 10 millions of records from database and writing to a text file. It takes hours of time to complete this operation. Is there any option to use TPL features here?
It would be great if someone could get me started implementing this with the TPL.
using (FileStream fStream = new FileStream("d:\\file.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
BufferedStream bStream = new BufferedStream(fStream);
TextWriter writer = new StreamWriter(bStream);
for (int i = 0; i < 100000000; i++)
{
writer.WriteLine(i);
}
bStream.Flush();
writer.Flush(); // empty buffer;
fStream.Flush();
}