Solved

javascript timer "locks up" the web page

Posted on 2014-10-14
9
147 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 57

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 57

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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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 57

Accepted Solution

by:
Julian Hansen earned 500 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 57

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 57

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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Find out what you should include to make the best professional email signature for your organization.
This article discusses how to implement server side field validation and display customized error messages to the client.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
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)

707 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