1 year ago

#356818

test-img

김수진

C# how to multiThread in Selenium ChromeDriver

I put 3 tasks on the list. I want the other 1 to be processed after 2 are done. However, if I put 3 threads in the list after limiting the threads to 3, the chrome driver is not created. My guess is that if there is no free thread, the chrome driver is not created.

It doesn't throw an exception and stops at all.

Does anyone have any idea why the ChromeDriver object is not created when there are no threads?

testFunction Source

static public void testFunction(object v) 
{
    ChromeDriverService _driverService = ChromeDriverService.CreateDefaultService(); 
    ChromeOptions _options = new ChromeOptions(); 
    ChromeDriver _driver = new ChromeDriver(_driverService, _options); //This is Not working    
    Console.WriteLine("This line is not reached.");
}

The Action is not Working!(But when I increase the number of threads to 4 it works fine.)

ThreadPool.SetMinThreads(1, 1);
ThreadPool.SetMaxThreads(3, 1000);
ThreadPool.QueueUserWorkItem(testFunction);
ThreadPool.QueueUserWorkItem(testFunction);
ThreadPool.QueueUserWorkItem(testFunction);

The Action is Good Working!

ThreadPool.SetMinThreads(1, 1);
ThreadPool.SetMaxThreads(3, 1000);
ThreadPool.QueueUserWorkItem(testFunction);
ThreadPool.QueueUserWorkItem(testFunction);
//ThreadPool.QueueUserWorkItem(testFunction);

c#

multithreading

selenium

selenium-chromedriver

threadpool

0 Answers

Your Answer

Accepted video resources