There are many answers out there about how to batch a fairly large DataSet into multiple chunked DataSets.
There are, however, not really solutions about how to do this without locking the UI while chunking these DataSets.
This solution works, but I'm supposed to await the async operation, but I don't know what to await in this code, so the operation executes synchronously:
internal static class ExtensionMethods
{
internal static async Task<List<DataTable>> CloneTable(DataTable tableToClone, int countLimit)
{
List<DataTable> tables = new List<DataTable>();
int count = 0;
DataTable copyTable = null;
foreach (DataRow dr in tableToClone.Rows)
{
if ((count++ % countLimit) == 0)
{
copyTable = new DataTable();
copyTable = tableToClone.Clone();
copyTable.TableName = "TableCount" + count;
tables.Add(copyTable);
}
copyTable.ImportRow(dr);
}
return tables;
}
}
How can I get this to execute asynchronously as opposed to synchronously?