Showing posts with label timer. Show all posts
Showing posts with label timer. Show all posts

Thursday, March 22, 2012

Thread & timer in Web application C#

Hi all,I am using web application to request some infomation to the validgateway and get the response. But in some time if we request theinvalid gateway it wont response. So the application does not doanything without the response. So I planned to use the thread and timerconcept. If I put the function in thread and used the timer concept. Inthe windows application i did the same using the thread and the timertick. I dont know how to implement in the web application. If anybodyknows please give me ur suggestions.

Hi,

You might get some idea from here,

http://ajax.asp.net/docs/overview/UsingTimerControlTutorial.aspxhttp://www.codeplex.com/AtlasControlToolkit/Release/ProjectReleases.aspx?ReleaseId=1813http://www.codeproject.com/Ajax/stoppabletimer.asphttp://www.codeproject.com/useritems/WebTimer.asp http://www.codeproject.com/aspnet/dhtml_timer.asp


use ajax....

<script>

var xmlHttp

function showHint()

{

//var url="concession/AJAX_Code.aspx"

var url="timeservice.asmx/HelloWorld"

xmlHttp=GetXmlHttpObject(stateChanged)

xmlHttp.open("post", url ,true)

xmlHttp.send(null)

window.setTimeout("showHint()",1000);

}

function stateChanged()

{

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

{

document.getElementById("lblDate").innerHTML=xmlHttp.responseText

}

}

function GetXmlHttpObject(handler)

{

var objXmlHttp=null

if (navigator.userAgent.indexOf("Opera")>=0)

{

alert("This example doesn't work in Opera")return

}

if (navigator.userAgent.indexOf("MSIE")>=0)

{

var strName="Msxml2.XMLHTTP"

if (navigator.appVersion.indexOf("MSIE 5.5")>=0)

{

strName="Microsoft.XMLHTTP"

}

try

{

objXmlHttp=new ActiveXObject(strName)

objXmlHttp.onreadystatechange=handler

return objXmlHttp

}

catch(e)

{

alert("Error. Scripting for ActiveX might be disabled")return

}

}

if (navigator.userAgent.indexOf("Mozilla")>=0)

{

objXmlHttp=new XMLHttpRequest()

objXmlHttp.onload=handler

objXmlHttp.onerror=handler

return objXmlHttp

}

}

</script>

//////////////And the webservice for this is

<WebMethod()> _

PublicFunction HelloWorld()AsString

Return Now.ToString("dd-MMMM-yyyy hh:mm:ss")

EndFunction

Tuesday, March 13, 2012

Thread Vs Timer ?

what is the difference between thread and timer.A thread is a parallel code execution line. If you have 10 threads in an application, this means 10 subprocess will run at the same time. The kind of subprocess depends on the code in the thread.
You can see a thread as a function/method that is executed in parallel instead of sequentially.

A timer is a countdown mechanisme. Most Timer systems use a thread that will do nothing until a given timespan elapses. Because it uses a thread, a timer does not interfere with normal program execution.
This guy again, still having others do your homework for you.