I am trying to create a program that will disable an equipment after a priod of time. To
disabled the equipment, a user would use our web application to set the time span before
the equipment would be disabled.

I first tried to accomplised this by using an AJAX method for asyncronous operation to
prevent the browser from locking up for the duration of the timespan. In addition, I
used the setTimeout method to set the time span after it has been converted to mil-second.

I understand most javascripts as well as any other programs are memory resident and the
implementation might not work (at least not consistantely) the way I planned it.

var duration = some value or (some remaining time);
function sendStopRequest(PID)
	    var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            var s2 = PID.replace("tel:", "");
            //var url = "http://trackfusion.gpsit.com/Alpha1/bllWebServices/webServices.asmx/StopRecorder";
            var url = "../bllWebServices/webServices.asmx/StopRecorder";
            xmlHttp.open("POST", url, true);
            xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            xmlHttp.onreadystatechange = function()
                if(xmlHttp.readystate == 4)
                    var response = xmlHttp.responseText;
                    var XMLObject = new ActiveXObject("Microsoft.XMLDOM");
                    XMLObject.async = false;
                        var status = XMLObject.getElementsByTagName("int").item(0).text;
                        if(status == 1)
                            //alert("going to sleep");
                            //window.setTimeout(" ", 5000);
                            setTimeout("turnOffDevice('PID1')", duration);
            xmlHttp.send('PID=' + s2);

After I programmed the above code, I used the

<body onunload="javascript:sendStopRequest('xxxxxxxxxxx');">

This code would allow the user to disconnect from our website
and still have the device running untill the duration value
has counted down to zero.

I do most of my development in C# but I don't know if this problem
can be resolved with C# or AJAX.

9 Years
Discussion Span
Last Post by justapimp

Hello Guys, I would like to know if anybody can help me with the above project. I really need some help pleeeeeeeeeeeease.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.