Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Timer control/ Threading/Backgroundworker

BenniitBenniit Posts: 7Member
The code below loops through all the records and checks if Allocation_Due_Date is equal to the current date. If a match is found, the tooltip displays it on a button on the form. My problem is a time will come and the records will be many which will cause the machine to hang. So if someone can help me place the below code in a thread to free the machine from hanging. Thank you
[code]

' The sub procedure 'AllocationExpiryDate' is called to the Tick event of the timer control.

Public Sub AllocationExpiryDate()
Dim SQLCon As New SqlConnection : Dim dtTable As New DataSet
strUsername = GetSetting("Allocation", "Connection", "DataL1")
strPassword = GetSetting("Allocation", "Connection", "DataL2")
strServerName = GetSetting("Allocation", "Connection", "DataL3")
strInitialCatalog = GetSetting("Allocation", "Connection", "DataL4")
DataL1 = strUsername & strPassword & strServerName & strInitialCatalog
SQLCon.ConnectionString = DataL1
Try
SQLCon.Open()
Dim Query As String = "Select * from Alloc order by Allocation_Due_Date asc"
daAdapter = New SqlDataAdapter(Query, SQLCon)
daAdapter.Fill(dtTable, "Alloc")
Dim table As DataTable = dtTable.Tables("Alloc")
If table.Rows.Count > 0 Then
Dim ctr As Integer
For ctr = 0 To table.Rows.Count - 1
Dim dtAllocExpDate = FormatDateTime(table.Rows(ctr).Item("Allocation_Due_Date").ToString.Trim, DateFormat.ShortDate)
If dtAllocExpDate = Now Then Then
frmMainForm.ToolTip1.Show("Allocation note is due for revision. Refer to the allocation list", frmMainForm.btnExpiry)
End If
Next
End If
Catch ex As Exception
MsgBox(Err.Description)
End Try
End Sub


[/code]
Sign In or Register to comment.