Solved

Timer does not fire during Send operation?

Posted on 2006-10-28
6
218 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to open Waze.com/livemap from address saved in DB? 26 189
Problem to skip loop 6 57
Access Object Property from VBA Module in Excel 2010 2 31
Child Form in front 4 47
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

777 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