I am using a backgroundworker to fill a bunch of datasets using tableadapter.fill(). For some reason they are causing the UI to be unresponsive. How is this even possible? I’m not reporting any information back to the UI with it…it’s just supposed to run in the background, no progressbar.
Me.spOpportunityTableAdapter.Fill(Me.DsBdPipeline.spOpportunity, CType(ActiveStatus, Integer))
Me.ClientTableAdapter.Fill(Me.DsBdPipeline.Client)
Me.ClientTypeTableAdapter.Fill(Me.DsBdPipeline.ClientType)
Me.ClientPriorityTableAdapter.Fill(Me.DsBdPipeline.ClientPriority)
Me.OpportunityStatusTableAdapter.Fill(Me.DsBdPipeline.OpportunityStatus)
Me.MarketSegmentTableAdapter.Fill(Me.DsBdPipeline.MarketSegment)
Me.ProcurementTypeTableAdapter.Fill(Me.DsBdPipeline.ProcurementType)
Me.BusDevProjectTableAdapter.Fill(Me.DsBdPipeline.BusDevProject)
Me.ProjectTableAdapter.Fill(Me.DsBdPipeline.Project)
Me.StateTableAdapter.Fill(Me.DsBdPipeline.State)
Me.OrgMapTableAdapter.Fill(Me.DsBdPipeline.OrgMap)
Me.EmployeeTableAdapter.Fill(Me.DsBdPipeline.Employee)
Me.ClientServiceManagerViewTableAdapter.Fill(Me.DsBdPipeline.ClientServiceManagerView)
Honestly I don’t know the why’s and wherefores of why this was having trouble for some users and not others, but here is what fixed the problem.
I traced it to the
TableAdapter.Fillmethods executing in the backgroundworkerDoWorkmethod. It made no sense to me that something executing on a background thread, and which was not updating the UI with it’s progress, would cause the UI to be unresponsive. So I figured it must be what the TableAdapter is filling being bound to a UI component and causing problems (only God knows why).So I took all the design-time databinding off the controls. I reordered things so that in the backgroundworker thread, the
TableAdapter‘s fill. In theRunWorkerCompletedmethod, I bind the controls to the BindingSource.And voila, problem solved.