0

I have created a program that tracks computer inventory. This program was written in Visual Studio 2013 and connects to a MySQL database. There is a piece of code that takes about 10 seconds to run and update 5 combo boxes with data from the MySQL database. This code is run every time a new serial number is queried against the MySQL database. The reason for this is that someone can be entering a new value on one of the tables and my program can run constantly and still pick up the changes with out having to exit the program and re-open it.

this.departmentsTableAdapter1.Fill(this.atrinventoryDataSet11.departments);
this.officelocationsTableAdapter.Fill(this.atrinventoryDataSet11.officelocations);
this.employeesTableAdapter.Fill(this.atrinventoryDataSet11.employees);
this.statusTableAdapter.Fill(this.atrinventoryDataSet11.status);   
this.equipmenttypesTableAdapter.Fill(this.atrinventoryDataSet11.equipmenttypes);

I have researched threading through Google search and many of the search results point to StackOverflow and I have not had any success in getting the combo boxes to update in the thread. Currently, I don't mind the wait but I'm trying to make my program as efficient as possible. My thoughts were to run each of the fills in a separate thread for maximum efficiency. Here is my code creating and calling threads.

ThreadStart job = new ThreadStart(UpdateDepartment);
Thread UpdateDepartments = new Thread(job);
UpdateDepartments.Start();

And here is my code for the actual thread.

public void UpdateDepartment()
{
    this.departmentsTableAdapter1.Fill(this.atrinventoryDataSet11.departments);
}

I need help with getting the combo boxes to update from a thread. I know I'm close. Any help would be greatly appreciated.

IT Minion
  • 9
  • 1
  • 2

0 Answers0