By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,758 Members | 1,264 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,758 IT Pros & Developers. It's quick & easy.

Asyncronous/AJAX Suggestions Please!

P: n/a
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

Sep 21 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi,

OJ wrote:
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
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Sep 21 '06 #2

P: n/a
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
Laurent Bugnion wrote:
Hi,

OJ wrote:
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
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Sep 22 '06 #3

P: n/a
Hi,

OJ wrote:
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
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Sep 22 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.