How to write Asynchronous LINQ query?
- by Morgan Cheng
After I read a bunch of LINQ related stuff, I suddenly realized that no articles introduce how to write asynchronous LINQ query.
Suppose we use LINQ to SQL, below statement is clear. However, if the SQL database responds slowly, then the thread using this block of code would be hindered.
var result = from item in Products where item.Price > 3 select item.Name;
foreach (var name in result)
{
Console.WriteLine(name);
}
Seems that current LINQ query spec doesn't provide support to this.
Is there any way to do asynchronous programming LINQ? It works like there is a callback
notification when results are ready to use without any blocking delay on I/O.