Solved

javascript timer "locks up" the web page

Posted on 2014-10-14
9
137 Views
Last Modified: 2014-10-16
i have a dll that raises events.  i have a javascript function event handler.  this works well, as long as I call a function in the dll to return the event.  but there are events that happen outside the browser that I need to respond to.  I created a javascript timer to fetch the events, but that won't let the page respond to button clicks, text box entry, etc.

how can i implement this so that the page stays responsive?  i am using straight javascript and html, the dll is loaded on the page as an embedded object.
0
Comment
Question by:dhenderson12
  • 5
  • 4
9 Comments
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
How are you fetching events outside the browser?
0
 

Author Comment

by:dhenderson12
Comment Utility
the dll has a function called "FetchEvents()".  so the object is:
 <object classid="clsid:55527FAD-5E60-4F44-867B-9F6E7B0DB9DD" id="ica">
        </object>

and the call is form1.ica.FetchEvents();
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
Are you doing something like this

setInterval('fetchEvents()', 1000);

function fetcEvents()
{
   // Make your call to the object here.
}

Open in new window


And you are saying that is causing the page to not be responsive? Why is that? Does the fetchEvents method take a long time to complete?
How often are you calling it?
0
 

Author Comment

by:dhenderson12
Comment Utility
here's the cycle:
1.  page loads and it logs into the object ( form1.ica.init() ) through javascript. (ica is a com dll).
2.  there is a javascript event handler at the top of the page, an when init() is called on ica, ica raises an event that is captured by the event handler.
3.  if I call another method on the object, like form1.ica.changestate(), i follow that with a call to form1.ica.FetchEvents(), which forces the event to be raised.

i want to put the FetchEvents() method on a javascript timer, but when I do the rest of the page becomes unresponsive.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 51

Accepted Solution

by:
Julian Hansen earned 500 total points
Comment Utility
It shouldn't - that is why I asked the question

What is your timeout
How long does it take for the call to the DLL to complete (in FetchEvents)

If your timeout is smaller than the time taken to process the call to the dll then that could cause the problem.
0
 

Author Comment

by:dhenderson12
Comment Utility
I increased the timeout to 60000 (60 seconds) but that didn't help.
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
It would help if there was a link or some code to look at - can you post your javascript implementation
0
 

Author Comment

by:dhenderson12
Comment Utility
thanks for your help, Julian, but I found a different solution.  I created an async version of the method I'm calling and it works like a champ.  I appreciate the time and the help.
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
Well that would do it - refer my comment earlier

How long does it take for the call to the DLL to complete (in FetchEvents)

Glad you got sorted though - thanks for the points and good luck with your project.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

771 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

7 Experts available now in Live!

Get 1:1 Help Now