Solved

Timer does not fire during Send operation?

Posted on 2006-10-28
6
217 Views
Last Modified: 2010-04-30
I have a timer that fires every 1/10 of a second and updates a label on a form. It works fine, but when the following code is executed:

    Dim oHTTP As New MSXML2.XMLHTTP
    ...
    oHTTP.send (DataToSend)

my VB6 program "looses program control" to the "send" operation for about 15 seconds. In other words, my timer event does not fire during the "send" operation. Is there any way to cause my timer to continue to fire at its interval during the "send" operation?
0
Comment
Question by:lee88
  • 3
  • 2
6 Comments
 
LVL 27

Expert Comment

by:Ark
ID: 17827135
This is IDE behavior. Just compile your app and everything will be OK. Or use SetTimer API
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 17827158
Hi lee88,

You could also use DoEvents with the CCRP timer:

http://ccrp.mvps.org/index.html?controls/ccrptimer6.htm


Cheers!
0
 

Author Comment

by:lee88
ID: 17827211
Ark: I compiled, but no change. I will try SetTimer API.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 27

Accepted Solution

by:
Ark earned 500 total points
ID: 17827276
Here is an example

'=======Module=========
Public Declare Function SetTimer& Lib "user32" (ByVal hwnd&, ByVal nIDEvent&, ByVal uElapse&, ByVal lpTimerFunc&)
Public Declare Function KillTimer& Lib "user32" (ByVal hwnd&, ByVal nIDEvent&)

Public Const MY_TIMER_MSG As Long = &H5000& 'Any value, but try to avoid standard qindows MSG values
Dim m_hWnd As Long

Public Sub TimerProc(ByVal hwnd&, ByVal uMsg&, ByVal idEvent&, ByVal dwTime&)
    'Your staff here (like in Timer1_Timer)
    'Even Call MyForm.Timer1_Timer
End Sub

Public Sub EnableTimer(Optional ByVal hwnd as Long, Optional ByVal TimerInterval As Long = 1000) 'TimerInterval in millisec
    m_hWnd=hWnd
    SetTimer hWnd, MY_TIMER_MSG, TimerInterval, AddressOf TimerProc
End Sub

Public Sub DisableTimer()
   KillTimer m_hWnd, MY_TIMER_MSG
End Sub

'Now just call
EnableTimer Me.hWnd, 500
'From your form
'Important! Don't forget to disable timer in Form_Unload event!
0
 

Author Comment

by:lee88
ID: 17827292
excellent. Thanks.
0
 
LVL 27

Expert Comment

by:Ark
ID: 17827302
Thanks for points, glad I could help you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel object stays open 19 70
VBA saving file message display 5 56
Sending a email via excel using vba 6 71
VB6 ListBox Question 4 30
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now