'C# Multithreading API calls
I am multithreading a list of API calls in Python like so:
from requests_toolbelt.threaded import pool
import multiprocessing
import api_credentials
import queue
def multi_process(urls)
cores_to_use = multiprocessing.cpu_count()
if cores_to_use > 10: cores_to_use = 10
jobs = queue.Queue()
for url in urls():
jobs.put({'method': 'GET', 'url': url, 'auth':(api_credentials.username, api_credentials.password)
pool_of_jobs = pool.Pool(job_queue=jobs, num_processes=cores_to_use)
pool_of_jobs.join_all()
return pool_of_jobs.responses()
What is the equivalent way of doing the above in C#?
I am getting the number of cores from:
int cores_to_use = Environment.ProcessorCount;
but I haven't found any clear example to achieve the above in C#.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
