|
-
Feb 7th, 2014, 04:56 PM
#1
Thread Starter
Lively Member
BackgroundWorker is currently busy and cannot run multiple tasks concurrently
I updated a vb.net project from vs 2005 to vs2013 and i get this error message BackgroundWorker is currently busy and cannot run multiple tasks concurrently
and this is my code
Code:
to get the clicked button and set the sql statment
Dim newfrm = DirectCast(sender, DevComponents.DotNetBar.ButtonItem)
Select Case newfrm.Name
Case "showallbtn"
showallbtn.Checked = True
showusergrid.PrimaryGrid.Caption.Text = "Clients & Fournisseur"
xxx = "SELECT * FROM clients "
Case "showclientbtn"
xxx = "SELECT * FROM [clients] WHERE type= 'Client' "
showclientbtn.Checked = True
showusergrid.PrimaryGrid.Caption.Text = "Clients"
Case "showfournbtn"
xxx = "SELECT * FROM clients WHERE type='Fournisseur' "
showfournbtn.Checked = True
showusergrid.PrimaryGrid.Caption.Text = "Fournisseur"
End Select
Code:
and this code is the backgroundworker code
Private Sub showallworker_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles showallworker.DoWork
If connection.State = ConnectionState.Open Then connection.Close()
connection.Open()
Dim myadapter As New OleDb.OleDbDataAdapter(xxx, connection)
Dim ds As New DataSet
myadapter.Fill(ds)
myadapter.Dispose()
Dim tbl As DataTable = ds.Tables(0)
Dim panel As GridPanel = showusergrid.PrimaryGrid
panel.Rows.Clear()
showusergrid.BeginUpdate()
For i As Integer = 0 To (tbl.Rows.Count.ToString - 1)
Dim civility = IIf(tbl.Rows(i).Item("civil") <> String.Empty, Space(1) & "(" & tbl.Rows(i).Item("civil") & ")", "")
panel.Rows.Add(New GridRow(tbl.Rows(i).Item("id"), tbl.Rows(i).Item("type"), tbl.Rows(i).Item("nom") & civility, tbl.Rows(i).Item("adresse"), tbl.Rows(i).Item("gsm"), tbl.Rows(i).Item("fax"), tbl.Rows(i).Item("bureau"), tbl.Rows(i).Item("domicile"), tbl.Rows(i).Item("postale")))
Next i
showusergrid.EndUpdate()
connection.Close()
End Sub
I used a special backgroundworker for every button but i got the same error
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|