Paulers,
And your goal with this is?
Beside making it complex and slowing the process down.
You can give your dataset to your main thread where your UI is in, however
as that can only after that it is filled. The process of updating you can do
in another thread, however you have to check if that has be done well before
you can go on with the rest of your processing.
Therefore you have to synchronise the asynchronis processing. A little bit
crazy in my idea and slurping processing time.
Just keeping it in one thread will synchronise this process in one time.
Just my idea.
Cor
"Paulers" <
[email protected]> schreef in bericht
Thanks for the replys
in my form I am declaring:
Public Delegate Sub DelegateUIUpdate(ByVal dgv As DataGridView,
ByVal ds As DataSet)
In the Button Click I have
Dim workerThread As Thread = New Thread(AddressOf
CallsByScriptWorker)
workerThread.Start()
then I have two subs, one to do the work and the other to update the
UI thread.
Sub CallsByScriptWorker()
Dim sb As StringBuilder = New StringBuilder
sb.Append("SELECT rcd.DateTime, rcd.DialedNumberString,")
sb.Append("rcd.TargetLabel as TargetVDN, ")
sb.Append("r.EnterpriseName as Route, ")
sb.Append("ms.EnterpriseName as Script, ")
sb.Append("rcd.FinalObjectID as Node, ")
sb.Append("rc.EnterpriseName, ")
sb.Append("rcd.ANI, ")
sb.Append("MAX(CASE WHEN ExpandedCallVariableID = 5000 THEN
ECCValue ELSE NULL END) AS CallType, ")
sb.Append("MAX(CASE WHEN ExpandedCallVariableID = 5001 THEN
ECCValue ELSE NULL END) AS ExternalID, ")
sb.Append("MAX(CASE WHEN ExpandedCallVariableID = 5002 THEN
ECCValue ELSE NULL END) AS ClientCode, ")
sb.Append("MAX(CASE WHEN ExpandedCallVariableID = 5003 THEN
ECCValue ELSE NULL END) AS FirstName, ")
sb.Append("MAX(CASE WHEN ExpandedCallVariableID = 5004 THEN
ECCValue ELSE NULL END) AS LastName, ")
sb.Append("MAX(CASE WHEN ExpandedCallVariableID = 5005 THEN
ECCValue ELSE NULL END) AS DOB, ")
sb.Append("MAX(CASE WHEN ExpandedCallVariableID = 5006 THEN
ECCValue ELSE NULL END) AS RefillComplete, ")
sb.Append("MAX(CASE WHEN ExpandedCallVariableID = 5010 THEN
ECCValue ELSE NULL END) AS RXArray ")
sb.Append("from Route_Call_Detail rcd ")
sb.Append("LEFT OUTER JOIN Route_Call_Variable rcv on
rcd.RecoveryKey = rcv.RCDRecoveryKey ")
sb.Append("LEFT OUTER JOIN Script s on s.ScriptID =
rcd.ScriptID ")
sb.Append("LEFT OUTER JOIN Master_Script ms on
ms.MasterScriptID = s.MasterScriptID ")
sb.Append("LEFT OUTER JOIN Routing_Client rc on
rcd.RoutingClientID = rc.RoutingClientID ")
sb.Append("LEFT OUTER JOIN Route r on r.RouteID = rcd.RouteID
")
sb.Append("where rcd.DateTime between '" &
Me.BeginDatePicker.Text & " " & Me.BeginTimePicker.Text & "' and '" &
Me.EndDatePicker.Text & " " & Me.EndTimePicker.Text & "' ")
sb.Append("and ms.EnterpriseName ='" &
Me.CallsByScripCombo.SelectedText & "' ")
sb.Append(" GROUP BY rcd.DateTime, rcd.DialedNumberString,
rcd.TargetLabel, r.EnterpriseName, ms.EnterpriseName,
rcd.FinalObjectID, rc.EnterpriseName, rcd.ANI ")
sb.Append("Order by rcd.DateTime ")
Dim Conn As SqlConnection = New SqlConnection(myConnString)
Dim DNDS As DataSet = New DataSet
Dim Adp As SqlDataAdapter = New
SqlDataAdapter(sb.ToString.ToString, Conn)
Adp.Fill(DNDS, "temp1")
Dim delUIUpdate As New DelegateUIUpdate(AddressOf UIUpdate)
Invoke(delUIUpdate, Me.CallsDataGridView, DNDS)
Conn.Close()
End Sub
Sub UIUpdate(ByVal dgv As DataGridView, ByVal ds As DataSet)
dgv.DataSource = ds.Tables(0).DefaultView
Me.CallsQueryButton.Enabled = True
End Sub- Hide quoted text -
- Show quoted text -