0
我有通過兩個並行爲每個循環發送Web請求的代碼。在此方法出現之前添加線程是否會導致這些任務的執行延遲,還是會實現更多Web請求?請求速度
for (int i = 0; i < threads; i++)
{
populateClient(ServerID, debugLog, type, mC);
tasks[i] = Task.Factory.StartNew(() =>
{
testMaps(ServerID, DebugLog, Type, mC.cl, mC.keywords, mC.locations);
});
}
while (tasks.Any(t => !t.IsCompleted)) { } //spin wait
// ...
static void testMaps(Int64 serverID, String debugLog, String type, ClientInfo cl,
List<Keyword> keywords,
List<String> locations)
{
Parallel.ForEach(keywords, keyword =>
{
Parallel.ForEach(locations, location =>
{
strFileName = file.DownloadString(query);
// ..
很酷的感謝,我擔心,我正在創造更多的開銷,這可能會減慢過程。 –