Showing posts with label request. Show all posts
Showing posts with label request. 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 restarting mid http request processing

I'm experiencing a really strange error at the moment, and was wondering if
anyone else has run into this.
This is a seemingly straightforward asp.net application -- i'm allowing the
user to make choices on a web form, collect the information, populate my
domain model, and then persist the domain model into session state which is
using the out of proc asp.net session state service.
The user behavior is that on a seemingly random interval, changes are simply
not persisted. Looking at the debugger, I can see that when this happens, m
y
thread responsible for processing the request is shut down and the request i
s
picked up by a new thread -- but apparently without the context of the
previous thread -- hence the data not being persisted.
Does anyone have any thoughts on why this is happening and how to go about
correcting?
tia,
_howardasp.net is thread agile, so switching threads is common. are you using any
STA components (vb6)? they will have this behavior in the agile model.
-- bruce (sqlwork.com)
"howard dierking" <howard dierking@.discussions.microsoft.com> wrote in
message news:0BF0E8CC-8FDB-4FEC-8360-13F665C19CBC@.microsoft.com...
> I'm experiencing a really strange error at the moment, and was wondering
if
> anyone else has run into this.
> This is a seemingly straightforward asp.net application -- i'm allowing
the
> user to make choices on a web form, collect the information, populate my
> domain model, and then persist the domain model into session state which
is
> using the out of proc asp.net session state service.
> The user behavior is that on a seemingly random interval, changes are
simply
> not persisted. Looking at the debugger, I can see that when this happens,
my
> thread responsible for processing the request is shut down and the request
is
> picked up by a new thread -- but apparently without the context of the
> previous thread -- hence the data not being persisted.
> Does anyone have any thoughts on why this is happening and how to go about
> correcting?
> tia,
> _howard
Hi Bruce,
no STA components - all asp.net
_howard
"bruce barker" wrote:

> asp.net is thread agile, so switching threads is common. are you using any
> STA components (vb6)? they will have this behavior in the agile model.
> -- bruce (sqlwork.com)
>
> "howard dierking" <howard dierking@.discussions.microsoft.com> wrote in
> message news:0BF0E8CC-8FDB-4FEC-8360-13F665C19CBC@.microsoft.com...
> if
> the
> is
> simply
> my
> is
>
>
are you using thread local storage? it will have the same problem. how are
you storing the model data? also when do you update the session?
-- bruce (sqlwork.com)
"howard dierking" <howarddierking@.discussions.microsoft.com> wrote in
message news:9D21988F-C431-4D66-B1BC-0959F9DB033A@.microsoft.com...
> Hi Bruce,
> no STA components - all asp.net
> _howard
>
> "bruce barker" wrote:
>
any
wondering
allowing
my
which
happens,
request
about
no explicit tls model data is stored as an actual session variable, so the
timing of it's persistance will be set by the normal control life cycle.
_howard
"bruce barker" wrote:

> are you using thread local storage? it will have the same problem. how are
> you storing the model data? also when do you update the session?
> -- bruce (sqlwork.com)
>
> "howard dierking" <howarddierking@.discussions.microsoft.com> wrote in
> message news:9D21988F-C431-4D66-B1BC-0959F9DB033A@.microsoft.com...
> any
> wondering
> allowing
> my
> which
> happens,
> request
> about
>
>

thread restarting mid http request processing

asp.net is thread agile, so switching threads is common. are you using any
STA components (vb6)? they will have this behavior in the agile model.

-- bruce (sqlwork.com)

"howard dierking" <howard dierking@dotnet.itags.org.discussions.microsoft.com> wrote in
message news:0BF0E8CC-8FDB-4FEC-8360-13F665C19CBC@dotnet.itags.org.microsoft.com...
> I'm experiencing a really strange error at the moment, and was wondering
if
> anyone else has run into this.
> This is a seemingly straightforward asp.net application -- i'm allowing
the
> user to make choices on a web form, collect the information, populate my
> domain model, and then persist the domain model into session state which
is
> using the out of proc asp.net session state service.
> The user behavior is that on a seemingly random interval, changes are
simply
> not persisted. Looking at the debugger, I can see that when this happens,
my
> thread responsible for processing the request is shut down and the request
is
> picked up by a new thread -- but apparently without the context of the
> previous thread -- hence the data not being persisted.
> Does anyone have any thoughts on why this is happening and how to go about
> correcting?
> tia,
> _howardHi Bruce,

no STA components - all asp.net

_howard

"bruce barker" wrote:

> asp.net is thread agile, so switching threads is common. are you using any
> STA components (vb6)? they will have this behavior in the agile model.
> -- bruce (sqlwork.com)
>
> "howard dierking" <howard dierking@.discussions.microsoft.com> wrote in
> message news:0BF0E8CC-8FDB-4FEC-8360-13F665C19CBC@.microsoft.com...
> > I'm experiencing a really strange error at the moment, and was wondering
> if
> > anyone else has run into this.
> > This is a seemingly straightforward asp.net application -- i'm allowing
> the
> > user to make choices on a web form, collect the information, populate my
> > domain model, and then persist the domain model into session state which
> is
> > using the out of proc asp.net session state service.
> > The user behavior is that on a seemingly random interval, changes are
> simply
> > not persisted. Looking at the debugger, I can see that when this happens,
> my
> > thread responsible for processing the request is shut down and the request
> is
> > picked up by a new thread -- but apparently without the context of the
> > previous thread -- hence the data not being persisted.
> > Does anyone have any thoughts on why this is happening and how to go about
> > correcting?
> > tia,
> > _howard
>
are you using thread local storage? it will have the same problem. how are
you storing the model data? also when do you update the session?

-- bruce (sqlwork.com)

"howard dierking" <howarddierking@.discussions.microsoft.com> wrote in
message news:9D21988F-C431-4D66-B1BC-0959F9DB033A@.microsoft.com...
> Hi Bruce,
> no STA components - all asp.net
> _howard
>
> "bruce barker" wrote:
> > asp.net is thread agile, so switching threads is common. are you using
any
> > STA components (vb6)? they will have this behavior in the agile model.
> > -- bruce (sqlwork.com)
> > "howard dierking" <howard dierking@.discussions.microsoft.com> wrote in
> > message news:0BF0E8CC-8FDB-4FEC-8360-13F665C19CBC@.microsoft.com...
> > > I'm experiencing a really strange error at the moment, and was
wondering
> > if
> > > anyone else has run into this.
> > > > This is a seemingly straightforward asp.net application -- i'm
allowing
> > the
> > > user to make choices on a web form, collect the information, populate
my
> > > domain model, and then persist the domain model into session state
which
> > is
> > > using the out of proc asp.net session state service.
> > > > The user behavior is that on a seemingly random interval, changes are
> > simply
> > > not persisted. Looking at the debugger, I can see that when this
happens,
> > my
> > > thread responsible for processing the request is shut down and the
request
> > is
> > > picked up by a new thread -- but apparently without the context of the
> > > previous thread -- hence the data not being persisted.
> > > > Does anyone have any thoughts on why this is happening and how to go
about
> > > correcting?
> > > > tia,
> > > > _howard