To access a single container in blob storage using multi thread, yesterday I started a bunch of threads myself and successfully did it.
Today a senior developer told me that to achieve the best system performance we'd better use the backgroud threads, in other words the "threadpool".
So I evolved my code and did it.
In the main thread, use a bool flag
while (running)
{
/* Omitted a lot */
BatchJob job = new BatchJob(_container, batch);
ThreadPool.QueueUserWorkItem(new WaitCallback(UploadBatch), job);
/* Omitted a lot */
}
By setting a max number for the threads in thread pool, you can control the number of threads accessing the microsoft windows azure blob storage.
ThreadPool.SetMaxThreads(numThread, 200);
No comments:
Post a Comment