?
Solved

javascript timer "locks up" the web page

Posted on 2014-10-14
9
Medium Priority
?
149 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 40380234
How are you fetching events outside the browser?
0
 

Author Comment

by:dhenderson12
ID: 40380421
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 58

Expert Comment

by:Julian Hansen
ID: 40380779
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:dhenderson12
ID: 40380857
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
 
LVL 58

Accepted Solution

by:
Julian Hansen earned 2000 total points
ID: 40380964
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
ID: 40384163
I increased the timeout to 60000 (60 seconds) but that didn't help.
0
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 40384199
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
ID: 40385419
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 58

Expert Comment

by:Julian Hansen
ID: 40386089
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

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Find out what you should include to make the best professional email signature for your organization.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

765 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