0

Anyone out there can help me with this problem. I have searched it even on google but find nothing. I have made a Windows Form Application for scraping some data. Problem is this when i click on the button the script starts in a headless mode and i am using Chrome Web-driver. It then freezes the application in a sense it did not let us use the other buttons on the application while running the script.

There's any solution to it or any other framework or thing which i can do?

Oxama Baig
  • 13
  • 2

2 Answers2

4

It has to do with the fact that your application is single-threaded. Means that all the code it executes, is run on a single thread. So you don't have a way to do some work while your user is changing the UI state and viceversa.

A good solution is to run the "selenium script" (or the routine that fires it) on a thread that is not the one your application is using for the UI.

You can achieve this in some ways:

Always remember that your default execution thread (in Windows Forms) is the one that keeps the UI and your application alive.

mororo
  • 1,074
  • 2
  • 11
  • 28
0

Put the actual work in a background task and not into the click handler of the button.

D.R.
  • 20,268
  • 21
  • 102
  • 205
  • background task? – Oxama Baig Mar 02 '19 at 12:00
  • Running a task in the background why UI is interactable: https://stackoverflow.com/questions/21419229/c-sharp-threading-async-running-a-task-in-the-background-while-ui-is-interactab – D.R. Mar 02 '19 at 12:02