Impossible de convertir de 'Système.Le filetage.Les tâches.La tâche' de 'Système.Les Collections.Génériques.Dictionnaire<string,string>'

Je crois que j'ai peut-être juste la syntaxe de mal, mais ce que j'essaie de faire est de créer une tâche qui s'exécute après l'autre tâche est terminée.

J'ai une tâche pour chaque tableau de 100 dans une liste. Il démarre un nouveau thread passage que tableau dans une méthode. La méthode retourne un dictionnaire quand il se termine. Je suis en train de créer une tâche à exécuter après la méthode est terminée, où il passe le retour de dictionnaire, à une méthode qui ne un peu plus de travail.

static void Main(string[] args)
{
try
{
stopwatch = new Stopwatch();
stopwatch.Start();
while (true)
{
startDownload();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
public static async void startDownload()
{
try
{
DateTime currentDay = DateTime.Now;
if (Helper.holidays.Contains(currentDay) == false)
{
List<string> markets = new List<string>() { "amex", "global", "nasdaq", "nyse" };
Parallel.ForEach(markets, async market =>
{
try
{
IEnumerable<string> symbolList = Helper.getStockSymbols(market);
var historicalGroups = symbolList.Select((x, i) => new { x, i })
.GroupBy(x => x.i / 100)
.Select(g => g.Select(x => x.x).ToArray());
Task<Dictionary<string, string>>[] historicalTasks =
historicalGroups.Select(x => Task.Run(() =>
Downloads.getHistoricalStockData(x, market)))
.ToArray();
Dictionary<string, string>[] historcalStockResults = await
Task.WhenAll(historicalTasks);
foreach (var dictionary in historcalStockResults)
{
Downloads.updateSymbolsInDB(dictionary);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
});
await Task.Delay(TimeSpan.FromHours(24));
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
  • Êtes-vous après un tableau de Task<Dictionary<string, string>> ou un tableau de Dictionary<string, string>?
  • Aussi, ce n' Downloads.updateSymbolsInDB retour?
  • public static async Task<Dictionnaire<string, string>> getHistoricalStockData(string[] les symboles, la chaîne de marché) j'ai besoin de passer à la Tâche<Dictionnaire<string, string>>
  • Le updateSymbols méthode ressemble à ceci et retourne void public static void updateSymbolsInDB(Dictionnaire<string, string> erreurs)
  • Va updateSymbolsInDB exécuter pour chaque résultat de getHistoricalStockData, ou est-il censé exécuter une seule fois sur l'ensemble de tous les getHistoricalStockData résultats?
  • J'ai essayé de l'exécuter en une seule fois parce que je pensais que ce serait plus efficace

InformationsquelleAutor user3610374 | 2014-12-25