B Ramirez

B Ramirez

  • NA
  • 6
  • 8.9k

Help implementing backgroundworker in app (beginner programmer)

Apr 19 2011 7:51 PM
Hello everyone,

I need a bit of help.

I'm working on a tool to automate a long process which is to setup the environment of some devices used for testing. The devices are configured remotely by using an application that connects to the devices through the network and then it deploys a particular version of the operating system onto the devices. I wanted to automate the process of configuring a number of devices in one batch rather than doing it one by one so I decided to write a small windows form application which is made of some textbox controls, for the IPs of the devices and an openfiledialog to select the application version used to deploy the OS/flash onto the devices. The windows form GUI executes this external process for each of the IPs entered into the textboxes and configures one by one. I managed to get it working, however, when it loops through the pool of IPs entered into the textboxes, since the it uses the same thread as the GUI, the GUI becomes unresponsive. After doing a bit of research I found about the backgroundworker which can be used to allocate a different thread to run these sort of heavy operations (such as deploying a particular flash to a number of devices in my case).

I started working with the backgroundworker but I'm not able to get it working - I'm not an experienced programmer.

I was wondering, can someone give me an example of the backgroundworker implementation where the application runs an external process and accesses GUI controls (such as textboxes to determine the target device IPs entered by the user in my case) and then executes this external process on a different thread for each of the IPs entered into the textboxes?

Any hints and code samples would be greatly appreciated.

Thanks in advance.

Answers (1)