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);
// ..
很酷的感谢,我担心,我正在创造更多的开销,这可能会减慢过程。 –