473,847 Members | 1,729 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Async method raised in web page doesn't refresh page

TS
Im in a web page and call an asynchronous method in business class. the call
back method is in the web page.

When page processes, it runs thru code begins invoking the method then the
page unloads. When the callback method is raised, only the method in the web
page is run and the page never refreshes, it seems it all happens on the
server side.

I am trying to refresh the constrols on the page inside the callback method,
but when id do, it isn't flushed to the browser.

Anyone know how i can do this with this long running async thread?

thanks a bunch!
Nov 19 '05 #1
8 5897
Right, it happens asynchronously. By the time it does a call back, the page
has no doubt finished processing, sent the results back to the client, and
has been displayed in the browser. The request is finished, the connection
is over.
"TS" <ma**********@n ospam.nospam> wrote in message
news:OF******** ********@TK2MSF TNGP15.phx.gbl. ..
Im in a web page and call an asynchronous method in business class. the
call
back method is in the web page.

When page processes, it runs thru code begins invoking the method then the
page unloads. When the callback method is raised, only the method in the
web
page is run and the page never refreshes, it seems it all happens on the
server side.

I am trying to refresh the constrols on the page inside the callback
method,
but when id do, it isn't flushed to the browser.

Anyone know how i can do this with this long running async thread?

thanks a bunch!

Nov 19 '05 #2
It's because the page has already completed rendering to the browser by the
time the aserver async event is raised. You need to have the page wait around
until the async work is done before it completes its rendering. Are you working
in 1.1 or 2.0? Fritz has an article on how to achieve this in v1.1:

http://msdn.microsoft.com/msdnmag/is...g/default.aspx

In 2.0 this is somewhat better integrated at the page level with the Async
Page feature.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Im in a web page and call an asynchronous method in business class.
the call back method is in the web page.

When page processes, it runs thru code begins invoking the method then
the page unloads. When the callback method is raised, only the method
in the web page is run and the page never refreshes, it seems it all
happens on the server side.

I am trying to refresh the constrols on the page inside the callback
method, but when id do, it isn't flushed to the browser.

Anyone know how i can do this with this long running async thread?

thanks a bunch!


Nov 19 '05 #3
TS,

You can't perform asynchronous operations on a web server like this and
expect the page to be refreshed accordingly. You will need to have your
operation complete, and then store the results of that operation on the
server.

Then, on the client side, you will have to poll some page over and over
again until the operation completes. When it does, you can get the results
and post them on the page accordingly.

You might also want to look into using XML on the page itself,
specifically, using the XML parser in javascript to load your data, and
update using dynamic HTML.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"TS" <ma**********@n ospam.nospam> wrote in message
news:OF******** ********@TK2MSF TNGP15.phx.gbl. ..
Im in a web page and call an asynchronous method in business class. the
call
back method is in the web page.

When page processes, it runs thru code begins invoking the method then the
page unloads. When the callback method is raised, only the method in the
web
page is run and the page never refreshes, it seems it all happens on the
server side.

I am trying to refresh the constrols on the page inside the callback
method,
but when id do, it isn't flushed to the browser.

Anyone know how i can do this with this long running async thread?

thanks a bunch!

Nov 19 '05 #4
> Then, on the client side, you will have to poll some page over and
over
again until the operation completes. When it does, you can get the
results
and post them on the page accordingly.

The server side code can ask the client to refresh like this:

// Ask client to refresh every 3 seconds
Response.Append Header("Refresh ", "3");

Next, you have to find a way to pass the results from the asynchronous
callback to the web page. I did this by passing the Session object in the
IAsyncResult.As yncState field. The Session object can then be accessed
from both the web page and the asynchronous callback function.

Works nicely, but watch out for concurrency issues...

Greetings,
Wessel
Nov 19 '05 #5
TS
I don't see how you can use the session in the async method, because that
method is the start of the new thread that doesn't has access to HTTPContext
object. Are you saying that you are passing the session object to the async
method and NOT that you are using the session object in async method and set
its return value to the session object?

thanks for your posts.

"Wessel Troost" <no*****@like.t he.sun> wrote in message
news:op.sujfpza 5f3yrl7@asbel.. .
Then, on the client side, you will have to poll some page over and
over
again until the operation completes. When it does, you can get the
results
and post them on the page accordingly.

The server side code can ask the client to refresh like this:

// Ask client to refresh every 3 seconds
Response.Append Header("Refresh ", "3");

Next, you have to find a way to pass the results from the asynchronous
callback to the web page. I did this by passing the Session object in the
IAsyncResult.As yncState field. The Session object can then be accessed
from both the web page and the asynchronous callback function.

Works nicely, but watch out for concurrency issues...

Greetings,
Wessel

Nov 19 '05 #6
TS
thanks for all the feedback. There seems to be some potential here.
"TS" <ma**********@n ospam.nospam> wrote in message
news:OF******** ********@TK2MSF TNGP15.phx.gbl. ..
Im in a web page and call an asynchronous method in business class. the call back method is in the web page.

When page processes, it runs thru code begins invoking the method then the
page unloads. When the callback method is raised, only the method in the web page is run and the page never refreshes, it seems it all happens on the
server side.

I am trying to refresh the constrols on the page inside the callback method, but when id do, it isn't flushed to the browser.

Anyone know how i can do this with this long running async thread?

thanks a bunch!

Nov 19 '05 #7
Hi TS,

AS for async processing in ASP.NET web application, direclty use the .net
delegation's Beginxxx call won't work quite work since when the underlying
working thread complete executing, the original httpRequest(in fact the
whole Httpcontext) may already been disposed. So currently two possible
async means we can choose are:
1. make a central async processing httphandler which do the time consuming
task. And we call this handler in the clientside page through clientside
script (using MSXML.XMLHTTP component) and pull data from serverside so as
to refresh our page.

2. consider adjusting our page's design and using the asp.net's buildin
page/handler level async processing model. The following msdn article(as
also mentioend by Brock ) has demonstarte this mode:

http://msdn.microsoft.com/msdnmag/is...g/default.aspx

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: "TS" <ma**********@n ospam.nospam>
| References: <OF************ **@TK2MSFTNGP15 .phx.gbl>
<OK************ **@tk2msftngp13 .phx.gbl> <op.sujfpza5f3y rl7@asbel>
| Subject: Re: Async method raised in web page doesn't refresh page
| Date: Tue, 26 Jul 2005 16:37:39 -0500
| Lines: 32
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <On************ **@TK2MSFTNGP14 .phx.gbl>
| Newsgroups:
microsoft.publi c.dotnet.framew ork.aspnet,micr osoft.public.do tnet.languages. c
sharp
| NNTP-Posting-Host: 103nat100.tea.s tate.tx.us 198.214.103.100
| Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP14.phx. gbl
| Xref: TK2MSFTNGXA01.p hx.gbl
microsoft.publi c.dotnet.langua ges.csharp:1124 06
microsoft.publi c.dotnet.framew ork.aspnet:1145 92
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| I don't see how you can use the session in the async method, because that
| method is the start of the new thread that doesn't has access to
HTTPContext
| object. Are you saying that you are passing the session object to the
async
| method and NOT that you are using the session object in async method and
set
| its return value to the session object?
|
| thanks for your posts.
|
| "Wessel Troost" <no*****@like.t he.sun> wrote in message
| news:op.sujfpza 5f3yrl7@asbel.. .
| > > Then, on the client side, you will have to poll some page over and
| > > over
| > > again until the operation completes. When it does, you can get the
| > > results
| > > and post them on the page accordingly.
| > >
| > The server side code can ask the client to refresh like this:
| >
| > // Ask client to refresh every 3 seconds
| > Response.Append Header("Refresh ", "3");
| >
| > Next, you have to find a way to pass the results from the asynchronous
| > callback to the web page. I did this by passing the Session object in
the
| > IAsyncResult.As yncState field. The Session object can then be accessed
| > from both the web page and the asynchronous callback function.
| >
| > Works nicely, but watch out for concurrency issues...
| >
| > Greetings,
| > Wessel
|
|
|

Nov 19 '05 #8
> I don't see how you can use the session in the async method, because that
method is the start of the new thread that doesn't has access to
HTTPContext object.
Accessing the HTTPContext from another thread might be OK, but I don't
think you can call it from an asynchronous callback. The context may not
be valid anymore when the callback is invoked.

But the Session is available to other threads for sure; the next thread
might be handled by another ASP.NET worker thread, after all.
Are you saying that you are passing the session object to the async
method and NOT that you are using the session object in async methodand
set its return value to the session object?

Actually I'm passing a reference to a data structure, like:

Context.Session[ "MyDataObje ct" ] = MyData;
AsyncCallback callback = new AsyncCallback( MyCallback );
BeginMyMethod( ..., callback, MyData );

The callback function looks like:

public static void MyCallback( IAsyncResult ar )
{
MyData = (MyDataClass) ar.AsyncState;
// Store results in MyData here.
// The Web Page can retrieve the results using
// Session["MyDataObje ct"].
}

Even if the Session ends, the MyData object will still exist.

Greetings,
Wessel
Nov 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
10465
by: Vanessa | last post by:
I have a question regarding async mode for calling Microsoft.XMLHTTP object. Microsoft.XMLHTTP hangs the IE once in a while suddenly, but it will work again after half an hour or so without doing anything. I have searched through the Internet and seems like the reason it hangs the browser it's because XMLHTTP limits you to two concurrent HTTP connections to each remote host; so if more than 2 concurrent connections strike the script...
0
1265
by: JDK | last post by:
This may be entirely the wrong forum for this message, but I wanted to give it a try. I am creating an ASPX page, with C# code behind, and am calling on a C# helper class, which in turn is wrapping a lot of functionality from a vendor's SDK. The SDK (which I have no source for, or visibility into) is actually Java-based; they wrote a COM (or COM+) wrapper for it long ago, and more recently created a .NET wrapper for *that*. I have a...
10
2973
by: Shawn Meyer | last post by:
Hello - I am trying to write a class that has an async BeginX and EndX, plus the regular X syncronous method. Delegates seemed like the way to go, however, I still am having problems getting exactly what I want. Here are my goals 1. I would like the IAsyncResult that is returned by the Begin function to be able to be waited on or polled to check for completion. 2. The Begin function would take a callback, and the async process would
6
1826
by: TS | last post by:
Im in a web page and call an asynchronous method in business class. the call back method is in the web page. When page processes, it runs thru code begins invoking the method then the page unloads. When the callback method is raised, only the method in the web page is run and the page never refreshes, it seems it all happens on the server side. I am trying to refresh the constrols on the page inside the callback method, but when id...
1
2289
by: jonathan | last post by:
I need to create a webpage that asynchronously loads a series of user controls onto a page. If the user control take longer than X seconds to load it should display an error message in it place. The rest of the page should continue to load whilst the seperate user control threads are loading. What is the correct way of doing this? I've created a delegate for loading the user control sand called
7
5081
by: =?Utf-8?B?Q2FybG8gRm9saW5p?= | last post by:
Hi, I implemented asynchronous calls to a web resource (using HttpWebRequest) from asp.net 2.0. The request it's made asyncronously (I see that beginGetResponse returns immediately). The number of worker thread and completionPortThreads are over 300. Making 200 calls I see that 100 are queued. There's a counter telling how much async calls are handled? How can I raise the number of request handled?
1
13261
by: 1388-2/HB | last post by:
I have a class file in my App_Code folder called "clsBasePage.vb" that looks like this: Public Class clsBasePage Inherits System.Web.UI.Page ...stuff... End Class It's a "page" in that it inherits from ui.page, but has no .aspx file. It's just a class file.
10
4520
by: Frankie | last post by:
It appears that System.Random would provide an acceptable means through which to generate a unique value used to identify multiple/concurrent asynchronous tasks. The usage of the value under consideration here is that it is supplied to the AsyncOperationManager.CreateOperation(userSuppliedState) method... with userSuppliedState being, more or less, a taskId. In this case, the userSuppliedState {really taskId} is of the object type,...
0
1580
by: Paul Hadfield | last post by:
Hi, From reading various articles on scalability issues, I understand that there is only a finite number of ASP.NET worker threads and any long running task within ASP.NET should be fired off on a seperate thread using an async call. All the articles I can find are either on implementing an async webpage, or calling an async webservice. I can not however find any article on how to make calls within a webservice asynchronous. Consider...
0
10647
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10338
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9482
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7882
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7056
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5719
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4119
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3164
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.