Solved

javascript timer "locks up" the web page

Posted on 2014-10-14
9
140 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 53

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 53

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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 53

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 53

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 53

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
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 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…

864 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

19 Experts available now in Live!

Get 1:1 Help Now