473,466 Members | 1,366 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Timer Control / Threading

54 New Member
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
Expand|Select|Wrap|Line Numbers
  1. ' The sub procedure 'AllocationExpiryDate' is called to the Tick event of the timer control. 
  2. Public Sub AllocationExpiryDate()
  3.         Dim SQLCon As New SqlConnection : Dim dtTable As New DataSet
  4.         strUsername = GetSetting("Allocation", "Connection", "DataL1")
  5.         strPassword = GetSetting("Allocation", "Connection", "DataL2")
  6.         strServerName = GetSetting("Allocation", "Connection", "DataL3")
  7.         strInitialCatalog = GetSetting("Allocation", "Connection", "DataL4")
  8.         DataL1 = strUsername & strPassword & strServerName & strInitialCatalog
  9.         SQLCon.ConnectionString = DataL1
  10.         Try
  11.             SQLCon.Open()
  12.             Dim Query As String = "Select * from Alloc order by Allocation_Due_Date asc"
  13.             daAdapter = New SqlDataAdapter(Query, SQLCon)
  14.             daAdapter.Fill(dtTable, "Alloc")
  15.             Dim table As DataTable = dtTable.Tables("Alloc")
  16.             If table.Rows.Count > 0 Then
  17.                 Dim ctr As Integer
  18.                 For ctr = 0 To table.Rows.Count - 1
  19.                     Dim dtAllocExpDate = FormatDateTime(table.Rows(ctr).Item("Allocation_Due_Date").ToString.Trim, DateFormat.ShortDate)
  20.                     If dtAllocExpDate = Now Then Then
  21.                         frmMainForm.ToolTip1.Show("Allocation note is due for revision. Refer to the allocation list", frmMainForm.btnExpiry)
  22.                     End If
  23.                 Next
  24.             End If
  25.         Catch ex As Exception
  26.             MsgBox(Err.Description)
  27.         End Try   
  28.     End Sub
  29.  
  30.  
  31.  
Jun 28 '13 #1
1 955
Frinavale
9,735 Recognized Expert Moderator Expert
Have you considered using a Thread?
The BackgroundWorker class is pretty useful for this type of thing. Check out this MSDN article about How to use the BackgroundWorker.

-Frinny
Jul 2 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: curious | last post by:
I am new to VB.NET and I need help in using timer control. Here is the scenario. I have 3 labels (label 1, label2, label 3), and a start button, all vertically aligned on the form. Using a...
3
by: David | last post by:
Hi There! I'm using Timer control to record how long my application perform certain tasks. However, apparently Timer control is not doing its' job (i.e. Not firing Tick event) while my...
3
by: Benny | last post by:
Hello Experts, Currently I am working on a windows application using VS.NET 2002 with C#. On one of my form, I have a refresh button which will dispose created controls and re-create them. I...
1
by: james.e.coleman | last post by:
Hello, System.Timers.Timer/System.Threading.Timer do not fire on my development server, yet they work perfectly on the production server. I would appreciate any help on what the cause of this...
1
by: abhishek007p | last post by:
HI, i am using visual web developer for .net 2.0. does .NET 2.0 comes with a timer control, i was unable to find it in the IDE, where is it ? thanks, Abhishek
17
by: Ratnesh Raval | last post by:
hi all, i m having some problem in timer control. sub timer.tick() timer.stop() do...something timer.enabled = true end sub
2
by: Umeshnath | last post by:
Hi, I have a web application that refreshes a label control every 1 sec (interval set by timer control). I am using Atlas panel for refreshing. Basically I have a method say PollMSMQ(), which...
5
by: Peted | last post by:
Just some threading questions 1. in a MDI app if you have multiple child forms, does each child form run in its own thread ? Eg do you get error trying to update one control on form1 from...
3
by: Steve | last post by:
Hi All I am using VB.net 2008 and use timer controls within my applications Question Does the code in a Timer control.tick event run on a different thread to the main Application thread (UI...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.