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! 6 1805
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**********@nospam.nospam> wrote in message
news:OF****************@TK2MSFTNGP15.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!
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.com
"TS" <ma**********@nospam.nospam> wrote in message
news:OF****************@TK2MSFTNGP15.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!
> 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.AppendHeader("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.AsyncState 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
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.the.sun> wrote in message
news:op.sujfpza5f3yrl7@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.AppendHeader("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.AsyncState 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
thanks for all the feedback. There seems to be some potential here.
"TS" <ma**********@nospam.nospam> wrote in message
news:OF****************@TK2MSFTNGP15.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!
> 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[ "MyDataObject" ] = 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["MyDataObject"].
}
Even if the Session ends, the MyData object will still exist.
Greetings,
Wessel This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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....
|
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...
|
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...
|
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...
|
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...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
| |