in code/KustoCopyConsole/Runner/TempTableCreatingRunner.cs [31:58]
public async Task RunAsync(CancellationToken ct)
{
var taskMap = new Dictionary<IterationKey, Task>();
while (taskMap.Any() || !AllActivitiesCompleted())
{
var newIterations = RowItemGateway.InMemoryCache.ActivityMap
.Values
.SelectMany(a => a.IterationMap.Values)
.Where(i => i.RowItem.State >= IterationState.Planning)
.Where(i => i.TempTable == null
|| i.TempTable.State == TempTableState.Creating)
.Select(i => new
{
Key = i.RowItem.GetIterationKey(),
Iteration = i
})
.Where(o => !taskMap.ContainsKey(o.Key));
foreach (var o in newIterations)
{
taskMap.Add(o.Key, EnsureTempTableCreatedAsync(o.Iteration, ct));
}
await CleanTaskMapAsync(taskMap);
// Sleep
await SleepAsync(ct);
}
}