Skip to content Skip to sidebar Skip to footer

What Is A Good Settimeout Interval For Polling In A Ie?

I have an ActiveX object (who source code I have) running in a browser (IE). The ActiveX object has a UI, which raises events. I want to respond to those events in the browser. I d

Solution 1:

I would recommend polling once every second. Do you really need instantaneous reactions?

Also, you shouldn't pass a string to setTimeout. Instead, you should pass the function itself, like htis:

setTimeout(pollForEvents, 1000);

Solution 2:

Start with 1 second, then, see how your response is.

if you need it faster, decrease the timeout period, but, you may find that below 20-50ms you won't get any improvement, due to the OS, and timeslicing, so threads can get adequate time.

I doubt you will see much cpu utilization, if you are not doing much, as, if it takes 1ms for it to do the operation, and it could be faster, then you spend most of your time sleeping, for this.

But, it really comes down to the user experience, and that is subjective. What may be acceptable to one person may seem slow to someone else.

So, find what you think is an appropriate value, then ask friends to try it and see what they think of the response. No point going faster just because you can, if there is no benefit.

Solution 3:

It depends on - how fast you want the ActiveX object to respond. - other factors that keep the CPU busy (flash animations, other polled functions)

Interval values don't reflect the actual values because of other factors. So, in your machine lower values can seem right but you can't be sure of the certainty at ohther clients. I recommend you to increase the interval as much as you can. If one second is adequate, that's fine.

Post a Comment for "What Is A Good Settimeout Interval For Polling In A Ie?"