473,664 Members | 2,995 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 17 '05 #1
6 1818
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 17 '05 #2
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 17 '05 #3
> 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 17 '05 #4
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 17 '05 #5
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 17 '05 #6
> 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 17 '05 #7

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

Similar topics

6
10449
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
1260
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
2950
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
8
5851
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...
6
3813
by: Shak | last post by:
Hi all, Three questions really: 1) The async call to the networkstream's endread() (or even endxxx() in general) blocks. Async calls are made on the threadpool - aren't we advised not to cause these to block? 2) You can connect together a binaryreader to a networkstream:
1
2282
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
5068
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
13247
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
4497
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
1572
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
8437
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
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
7375
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...
0
5660
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
4185
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
2764
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
2003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1759
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.