Ví dụ, sự khác biệt giữa mã nàySự khác biệt giữa việc sử dụng chỉ asynс Nhiệm vụ và Tác vụ là gì?
public Task<IList<NewsSentimentIndexes>> GetNewsSentimentIndexes(DateTime @from, DateTime to = new DateTime(), string grouping = "1h")
{
var result = _conf.BasePath
.AppendPathSegment("news-sentiment-indexes")
.SetQueryParams(new
{
from = from.ToString("s"),
to = to.ToString("s"),
grouping
});
return result
.GetStringAsync()
.ContinueWith(Desereialize<IList<NewsSentimentIndexes>>);
}
và
public async Task<IList<NewsSentimentIndexes>> GetNewsSentimentIndexes(DateTime @from, DateTime to = new DateTime(), string grouping = "1h")
{
var result = _conf.BasePath
.AppendPathSegment("news-sentiment-indexes")
.SetQueryParams(new
{
from = from.ToString("s"),
to = to.ToString("s"),
grouping
});
var newsStr = await result.GetStringAsync();
return JsonConvert.DeserializeObject<NewsSentimentIndexes>(newsStr);
}
Cái nào là đúng hoặc làm việc nhanh hơn? Và chỉ cần gọi phương pháp này cần phải chờ đợi hoặc chỉ là một nhiệm vụ?
Hãy cho tôi biết làm thế nào để có một WaitAll và sự tiếp tục của họ. Nó là không thể sử dụng chờ đợi –
'Task.WaitAll ( _newsService.GetAll (DateTime.Now.AddYears (-1), để: DateTime.Now) .ContinueWith (ContinuationAction), _tradingPairService.GetAllExchangeTradingPairAsync (ExchangeId, TradingPairId) .ContinueWith (ContinuationAction), _companyTypesService.GetAll(). ContinueWith (ContinuationAction)); ' –
Tôi đọc blog của bạn cảm ơn bạn, nhưng bạn phải WaitAll ví dụ, với các nhiệm vụ tương tự. Với sự tiếp tục của cùng một –