Click here to Skip to main content
15,905,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
actually my code is every 10 Sec Software Auto Check and Email to Client but problem is whenever timer starts every time form can accessible by user, every time software is hanging please help me how can i need to work as backgroundly because my email code get data from customer database and after it send auto as per email address.

VB
Private Sub frmMail_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
   tm_Email.Interval =  600000
   tm_Email.Start()
End Sub
Private Sub tm_Email_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tm_Email.Tick
 If IsConnectionAvailable() = True Then
   sendMail()
 else
  tm_Email.Interval =  600000
 End if


End Sub
private sub  sendMail()
 ' Mail Code by CLient wise
End sub

Here is my Code please help me
Posted
Comments
Allan Chong 24-Mar-14 6:06am    
Use theading for ur timer

You should run the blocking operation on a separate thread. See this Code Project article: "BackgroundWorker Class Sample for Beginners"[^].
 
Share this answer
 
If you are using .net 4+ then try using Tasks
VB
Private Sub tm_Email_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tm_Email.Tick
   Task.Factory.StartNew(
     Sub()  
       If IsConnectionAvailable() = True Then
          sendMail()
       else
          tm_Email.Interval =  600000
       End If
     End Sub
   )
End Sub
 
Share this answer
 
Comments
hareshdgr8 1-Apr-14 7:24am    
can you please tell me i am using vb.net 2005
Mehdi Gholam 1-Apr-14 11:10am    
For .net 2 look at Thread : http://msdn.microsoft.com/en-us/library/system.threading.threadstart.aspx
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900