Hi,
I'm trying to develop an application which searches a sql server database. One particular search entered by the user actually sends seven queries to the database. I've designed it so each of the seven queries is conducted in a seperate backgroundworker, so that they run and return their hits concurrently. When the user enters a search term, a routine (runSearch) is called , which in turn causes each seperate backgroundworker to run.
This work fine when the user enters a single search term.
I'm now trying to allow the user to enter multiple search terms in a multiline textbox. I iterate through the lines in the textbox and call runsearch for each line. I assumed that the progam would wait for each call to runsearch to complete, before running the next.
I now find out this is not the case. When I call runSearch, the backgroundworkers are set in motion. The next line in the textbox then calls runSearch again, but the backgroundworkers from the previous calling of runSearch are still running. This throws up an error stating that the backgroundworker is still busy and cannot be called.
I need a way to test that all of the backgroundworkers have completed before running runsearch again. If one or more of the backgroundworkers are still running, I need to wait before calling runSearch.
I'd appreciate any pointers as to how to acheive this. I'm fairly new to VB so sample code/examples would be great.
thanks
Jason
I'm trying to develop an application which searches a sql server database. One particular search entered by the user actually sends seven queries to the database. I've designed it so each of the seven queries is conducted in a seperate backgroundworker, so that they run and return their hits concurrently. When the user enters a search term, a routine (runSearch) is called , which in turn causes each seperate backgroundworker to run.
This work fine when the user enters a single search term.
I'm now trying to allow the user to enter multiple search terms in a multiline textbox. I iterate through the lines in the textbox and call runsearch for each line. I assumed that the progam would wait for each call to runsearch to complete, before running the next.
I now find out this is not the case. When I call runSearch, the backgroundworkers are set in motion. The next line in the textbox then calls runSearch again, but the backgroundworkers from the previous calling of runSearch are still running. This throws up an error stating that the backgroundworker is still busy and cannot be called.
I need a way to test that all of the backgroundworkers have completed before running runsearch again. If one or more of the backgroundworkers are still running, I need to wait before calling runSearch.
I'd appreciate any pointers as to how to acheive this. I'm fairly new to VB so sample code/examples would be great.
thanks
Jason