बाद में निष्पादन के लिए मैं TPL- आधारित कार्यों के List<T>
को कैसे विलय करूं?मैं दो लिंक INumerable <T> क्वेरी चलाने के बिना कैसे विलय कर सकता हूं?
public async IEnumerable<Task<string>> CreateTasks(){ /* stuff*/ }
मेरे धारणा .Concat()
है ...
void MainTestApp() // Full sample available upon request.
{
List<string> nothingList = new List<string>();
nothingList.Add("whatever");
cts = new CancellationTokenSource();
delayedExecution =
from str in nothingList
select AccessTheWebAsync("", cts.Token);
delayedExecution2 =
from str in nothingList
select AccessTheWebAsync("1", cts.Token);
delayedExecution = delayedExecution.Concat(delayedExecution2);
}
/// SNIP
async Task AccessTheWebAsync(string nothing, CancellationToken ct)
{
// return a Task
}
मुझे यकीन है कि यह किसी भी काम के लिए अंडे नहीं होगा या कुछ भी मूल्यांकन करना चाहते हैं। असल में, मुझे लगता है कि मैं पूछ रहा हूं "डेटा लौटने वाले किसी चीज़ के लिए एक IQueryable को तर्कसंगत रूप से निष्पादित करता है"?
पृष्ठभूमि
जब से मैं प्रत्यावर्तन कर रहा हूँ और मैं सही समय है जब तक इस पर अमल नहीं करना चाहती, अगर कहा जाता है कई बार परिणाम विलय करने के लिए सही तरीका क्या है?
यह मायने रखता है कि मैं सभी कार्य var AllRunningDataTasks = results.ToList();
इस कोड के बाद शुरू करने के लिए इस आदेश को चलाने का सोच रहा हूँ, तो:
while (AllRunningDataTasks.Count > 0)
{
// Identify the first task that completes.
Task<TableResult> firstFinishedTask = await Task.WhenAny(AllRunningDataTasks);
// ***Remove the selected task from the list so that you don't
// process it more than once.
AllRunningDataTasks.Remove(firstFinishedTask);
// TODO: Await the completed task.
var taskOfTableResult = await firstFinishedTask;
// Todo: (doen't work)
TrustState thisState = (TrustState)firstFinishedTask.AsyncState;
// TODO: Update the concurrent dictionary with data
// thisState.QueryStartPoint + thisState.ThingToSearchFor
Interlocked.Decrement(ref thisState.RunningDirectQueries);
Interlocked.Increment(ref thisState.CompletedDirectQueries);
if (thisState.RunningDirectQueries == 0)
{
thisState.TimeCompleted = DateTime.UtcNow;
}
}
क्यों संगत काम नहीं कर रहा है, इसे काम करना चाहिए? साथ ही, आप कार्य नहीं करना चाहते हैं, लेकिन क्वेरी चलाना ठीक है, आरटीटी? – Tilak
@ टिलक मेरा ध्यान कार्य पर है, और यह पहली बार कार्य या प्रश्नों पर ऐसा करने वाला है। मैंने कभी प्रश्नों के साथ ऐसा नहीं किया, लेकिन मुझे याद है कि कंसट यह है कि यह कैसे किया जाता है। – LamonteCristo
@ टिलक शायद मुझे अपने कोड में एक बग मिला ... जल्द ही अपडेट हो जाएगा – LamonteCristo