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
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
' 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
Dim Query As String = "Select * from Alloc order by Allocation_Due_Date asc"
daAdapter = New SqlDataAdapter(Query, SQLCon)
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)
Catch ex As Exception
0 · ·