Asyncronous/AJAX Suggestions Please!

O

OJ

Hi,
I have written a small C# 2.0 DLL which acts as a client to a Socket
based server over the internet. I have written both synchronous and
asynchronous methods to connect, send, and receive data from the
server. Each request/response can take upto 180 seconds. I am trying to
use the asyncronous calls in an ASP.NET C# 2.0 Webcontrol, which
displays the returned data. At the moment I am happily using the
asyncronous functions and events in my ASP.NET Usercontrol, but I am
having to block the main ASP.NET thread until the worker threads
dealing with the server response notifies my control that it has
returned all data. Then I render the control with all the returned
data. Obviously this destroys the advantage of the async functions.
There is an event firing in the dll that notifies me when new data has
arrived whilst waiting for all data to return. What I would really like
is to render the page to the client and then asynchronously update the
control from the server with the data that has arrived, before all data
has arrived. Could anybody point me in the right direction to implement
this?

OJ
 
L

Laurent Bugnion

Hi,
Hi,
I have written a small C# 2.0 DLL which acts as a client to a Socket
based server over the internet. I have written both synchronous and
asynchronous methods to connect, send, and receive data from the
server. Each request/response can take upto 180 seconds. I am trying to
use the asyncronous calls in an ASP.NET C# 2.0 Webcontrol, which
displays the returned data. At the moment I am happily using the
asyncronous functions and events in my ASP.NET Usercontrol, but I am
having to block the main ASP.NET thread until the worker threads
dealing with the server response notifies my control that it has
returned all data. Then I render the control with all the returned
data. Obviously this destroys the advantage of the async functions.
There is an event firing in the dll that notifies me when new data has
arrived whilst waiting for all data to return. What I would really like
is to render the page to the client and then asynchronously update the
control from the server with the data that has arrived, before all data
has arrived. Could anybody point me in the right direction to implement
this?

OJ

The best way to do what you want is to render the basic HTML "framework"
to the web client, so that the user has something to see instead of a
blank page. Then you use XmlHttpRequest in JavaScript to poll the server.

If you don't want to program the XmlHttpRequest yourself, there are
(too) many AJAX frameworks available. The most well know is prototype,
but JavaScript experts usually recommend against it. One I like is Matt
Kruse's AJAX toolbox
http://www.ajaxtoolbox.com/

Note that programming the XmlHttpRequest is not that difficult,
especially for simple requests.

The server typically sends back text, HTML or XML. It's your task then
to use client-side JavaScript and DOM Level 2 methods to replace nodes
content with the text or HTML returned from the server, or to use the
XML content.

Please feel free to ask more if you have more questions (you'll probably
have), this is just a short intro to AJAX.

Greetings,
Laurent
 
O

OJ

Hi Laurent,
I appreciate the time you have taken to reply. I will take a look at
the site you recommended. To be honest, I too was swamped by AJAX/ATLAS
stuff when I was trying to find out about this technique...

Perhaps my next post on this subject will be in the Javascript
group.....

O
 
L

Laurent Bugnion

Hi,
Hi Laurent,
I appreciate the time you have taken to reply. I will take a look at
the site you recommended. To be honest, I too was swamped by AJAX/ATLAS
stuff when I was trying to find out about this technique...

I am not a huge fan of libraries in JavaScript. I prefer to write my own
stuff, I find the learning effect better. It's really fun to do AJAX,
and I'll say it again, not very difficult.
Perhaps my next post on this subject will be in the Javascript
group.....

I am there too.
comp.lang.javascript

Greetings,
Laurent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top