473,326 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

asynchronous callbacks

I have a few processor intensive methods in my webservice which I need
to call from my web application.
After completion of these processes I need notification of whether
they were successful or not.

I can do this with delegates and by using BeginInvoke to update the UI
in a windows app but I can't
quite figure out how to do this in a web app.
This is what I have so far.

private void Button1_Click(object sender, System.EventArgs e)
{
AsyncCallback cb = new AsyncCallback(this.callback);
IAsyncResult ar = svcs.BeginProcess(this.TextBox1.Text, cb, svcs);
}

public void callback(IAsyncResult ar )
{
localhost.TestService svcs;
svcs = (localhost.TestService)ar.AsyncState;

bool reply = svcs.EndProcess(ar);

// Need to update UI
// #################
}

Jun 18 '07 #1
4 1263
this will not work with a web page. while asp.net may look like a
windows app it not. the browser requests an html page, and asp.net send
one back. if the user clicks a button, thats just another request, the
page class is created, events called, html produced then sent back to
the browser.

if your page starts an async process and does not stall until complete
(say in pre-render or onload) then when the async completes, the browser
has already received the response html and closed the connection.

to do what you want your page need to start a background thread (should
use a pool) that processes the aync process. then have the browser poll
for completion with a javascript or a meta refresh tag.

-- bruce (sqlwork.com)

jediknight wrote:
I have a few processor intensive methods in my webservice which I need
to call from my web application.
After completion of these processes I need notification of whether
they were successful or not.

I can do this with delegates and by using BeginInvoke to update the UI
in a windows app but I can't
quite figure out how to do this in a web app.
This is what I have so far.

private void Button1_Click(object sender, System.EventArgs e)
{
AsyncCallback cb = new AsyncCallback(this.callback);
IAsyncResult ar = svcs.BeginProcess(this.TextBox1.Text, cb, svcs);
}

public void callback(IAsyncResult ar )
{
localhost.TestService svcs;
svcs = (localhost.TestService)ar.AsyncState;

bool reply = svcs.EndProcess(ar);

// Need to update UI
// #################
}
Jun 18 '07 #2

You can check this article out:

http://msdn.microsoft.com/msdnmag/is...10/WickedCode/

which allows ~some async coding.

I haven't implemented it yet. But Jeff suggested to "use wisely and ONLY
where you need it"
and "Integrate 1 page at a time, not wholesale".

...
"jediknight" <wa*****@gmail.comwrote in message
news:11**********************@i38g2000prf.googlegr oups.com...
I have a few processor intensive methods in my webservice which I need
to call from my web application.
After completion of these processes I need notification of whether
they were successful or not.

I can do this with delegates and by using BeginInvoke to update the UI
in a windows app but I can't
quite figure out how to do this in a web app.
This is what I have so far.

private void Button1_Click(object sender, System.EventArgs e)
{
AsyncCallback cb = new AsyncCallback(this.callback);
IAsyncResult ar = svcs.BeginProcess(this.TextBox1.Text, cb, svcs);
}

public void callback(IAsyncResult ar )
{
localhost.TestService svcs;
svcs = (localhost.TestService)ar.AsyncState;

bool reply = svcs.EndProcess(ar);

// Need to update UI
// #################
}

Jun 18 '07 #3
You can use AJAX calls so the page can check the status of the operation
every so often.
Here's more info:
http://SteveOrr.net/articles/ajax.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"jediknight" <wa*****@gmail.comwrote in message
news:11**********************@i38g2000prf.googlegr oups.com...
>I have a few processor intensive methods in my webservice which I need
to call from my web application.
After completion of these processes I need notification of whether
they were successful or not.

I can do this with delegates and by using BeginInvoke to update the UI
in a windows app but I can't
quite figure out how to do this in a web app.
This is what I have so far.

private void Button1_Click(object sender, System.EventArgs e)
{
AsyncCallback cb = new AsyncCallback(this.callback);
IAsyncResult ar = svcs.BeginProcess(this.TextBox1.Text, cb, svcs);
}

public void callback(IAsyncResult ar )
{
localhost.TestService svcs;
svcs = (localhost.TestService)ar.AsyncState;

bool reply = svcs.EndProcess(ar);

// Need to update UI
// #################
}
Jun 18 '07 #4
On 18 Jun, 19:15, "Steve C. Orr [MCSD, MVP, CSM, ASP Insider]"
<S...@Orr.netwrote:
You can use AJAX calls so the page can check the status of the operation
every so often.
Here's more info:http://SteveOrr.net/articles/ajax.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsiderhttp://SteveOrr.net

"jediknight" <wakt...@gmail.comwrote in message

news:11**********************@i38g2000prf.googlegr oups.com...
I have a few processor intensive methods in my webservice which I need
to call from my web application.
After completion of these processes I need notification of whether
they were successful or not.
I can do this with delegates and by using BeginInvoke to update the UI
in a windows app but I can't
quite figure out how to do this in a web app.
This is what I have so far.
private void Button1_Click(object sender, System.EventArgs e)
{
AsyncCallback cb = new AsyncCallback(this.callback);
IAsyncResult ar = svcs.BeginProcess(this.TextBox1.Text, cb, svcs);
}
public void callback(IAsyncResult ar )
{
localhost.TestService svcs;
svcs = (localhost.TestService)ar.AsyncState;
bool reply = svcs.EndProcess(ar);
// Need to update UI
// #################
}- Hide quoted text -

- Show quoted text -
Thanks guys!

Desktop development and web development are quite different!!

Jun 19 '07 #5

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

Similar topics

9
by: Sam Loveridge | last post by:
Hi all. I'm relatively new to delegates and asynchronous threading and am running into an issue. I need to asynchronously call a method (which I'm doing with a delegate and BeginInvoke) and from...
4
by: theBoringCoder | last post by:
Hello All, I just started learning about Delegates, and was wondering if someone could point me at some useful, straightforward examples of how to use delegates to make method calls...
4
by: Matthew Groch | last post by:
Hi all, I've got a server that handles a relatively high number of concurrent transactions (on the magnitude of 1000's per second). Client applications establish socket connections with the...
0
by: Kruz | last post by:
Somewhere around 500 connections when calls (BeginSend calls) are arround 108,752 and total bytes sent are around 9,496,399 bytes - send callbacks (EndSend) stop coming in C# asynchronous sockets....
4
by: jim | last post by:
Hi All, I try to make an asynchronous call to a web service method as below under MS visual .NET studio 2003: WebService webSrv = new WebService(); AsyncCallback cb = new...
2
by: Ann Huxtable | last post by:
Hi, I want to do two types of async callbacks in C#. One involves spawning a worker thread, and the other does not invlve threads: Case 1 (Span new thread) ---------------------------- class...
4
by: taskswap | last post by:
I have a legacy application written in C that I'm trying to convert to C#. It processes a very large amount of data from many clients (actually, upstream servers - this is a mux) simultaneously. ...
1
by: dba123 | last post by:
I need to perform Asynchronous Inserts using DAAB. So far I have a method which does an insert but how can I do this Asyncronously so that it does not affect the load on our public production...
2
by: mark.norgate | last post by:
Hello The thing that interested me more about ASP.NET 2.0 before it came out was asynchronous web pages. Now it's here and I have time to investigate, I'd like to know about how to write pages...
1
by: Alper AKCAYOZ | last post by:
Hello, I have developped asynchronous socket communication with blocking Socket commands (accept, connect, send, receive) by using threads on Windows .NET Forms. It is working properly. Now I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.