Search code examples
c#linqpad

LINQPad Dump(toDataGrid) doesn't display until end of execution


I'm working on a little script in LINQPad for automatic batch mailing. Despite having the data being validated by the script, I would like to have it checked by someone and his confirmation. And, the following is my attempt at the sanity check :

var datasource = Enumerable.Range(0, 10) //not actual data
    .Dump("Data", true);

var message = string.Format("Please enter {0} to confirm or -1 to cancel : ", datasource.Count());
var container = new DumpContainer(message).Dump("Last Confirmation");
do
{
    var result = Console.ReadLine();
    container.Content = (container.Content as string) + result;

    if (result == "-1") return;
    if (result == datasource.Count().ToString()) break;

    container.Content = (container.Content as string) + "\n" + message;
} while (true);

//do stuffs...

Most of it work great, except that the datasource is not being dumped until end of execution which defeat whole purpose of this block of code. How can I make the Data tab display immediately?

Please note that I intended to dump the datasource into a new DataGrid tab, as it cannot be easily scanned through nor exported to excel.


Solution

  • This is now fixed in v4.51.03 (in beta at time of writing).

    Use the new Util.ReadLineAsync method:

    for (int i = 0; i < 10; i++)
    {
        int x = await Util.ReadLineAsync<int> ("Enter a number");
        Enumerable.Range (0, x).Dump (x + " integers", true);
    }