Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Asynchronous Callback Not Updating Web Page???

Reply
Thread Tools

Asynchronous Callback Not Updating Web Page???

 
 
TC
Guest
Posts: n/a
 
      05-06-2004
Hello,

I am making an asynchronous call to a webservice and trying to update the
web page with the results.

The page is not updating.

Does anybody know why???

Below is my code:

public class ASPNetSuperhero : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList drplstFilePaths;
protected System.Web.UI.WebControls.TextBox txtMessage;
protected System.Web.UI.WebControls.Button btnStartFileSearch;

private localhost.ASPNetSuperheroService GetWordCount;
protected System.Web.UI.WebControls.Label lblWordCount;
private AsyncCallback MyWordCountCallback;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnStartFileSearch.Click += new
System.EventHandler(this.btnStartFileSearch_Click) ;
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void btnStartFileSearch_Click(object sender, System.EventArgs e)
{
MyWordCountCallback = new AsyncCallback(WordCountCallback);
/* Create new instance of the webservice that provides
the required functionality*/
GetWordCount=new localhost.ASPNetSuperheroService();
GetWordCount.BeginWordCount(MyWordCountCallback,Ge tWordCount);
}

private void WordCountCallback(IAsyncResult Result)
{
// Call the webservice method in order to get current word count
this.txtMessage.Text=GetWordCount.EndWordCount(Res ult);
}
}


Regards,

TC


 
Reply With Quote
 
 
 
 
avnrao
Guest
Posts: n/a
 
      05-06-2004
if you are calling web service from an ASP.Net page on the server side, you
need wait till the call completes. use IAsynchResult.WaitHandle.WaitOne()
check this if you need more info..
http://msdn.microsoft.com/library/de...ce09032002.asp

Av.
http://www.avnrao.blogspot.com


"TC" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I am making an asynchronous call to a webservice and trying to update the
> web page with the results.
>
> The page is not updating.
>
> Does anybody know why???
>
> Below is my code:
>
> public class ASPNetSuperhero : System.Web.UI.Page
> {
> protected System.Web.UI.WebControls.DropDownList drplstFilePaths;
> protected System.Web.UI.WebControls.TextBox txtMessage;
> protected System.Web.UI.WebControls.Button btnStartFileSearch;
>
> private localhost.ASPNetSuperheroService GetWordCount;
> protected System.Web.UI.WebControls.Label lblWordCount;
> private AsyncCallback MyWordCountCallback;
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> }
>
> #region Web Form Designer generated code
> override protected void OnInit(EventArgs e)
> {
> //
> // CODEGEN: This call is required by the ASP.NET Web Form Designer.
> //
> InitializeComponent();
> base.OnInit(e);
> }
>
> /// <summary>
> /// Required method for Designer support - do not modify
> /// the contents of this method with the code editor.
> /// </summary>
> private void InitializeComponent()
> {
> this.btnStartFileSearch.Click += new
> System.EventHandler(this.btnStartFileSearch_Click) ;
> this.Load += new System.EventHandler(this.Page_Load);
>
> }
> #endregion
>
> private void btnStartFileSearch_Click(object sender, System.EventArgs e)
> {
> MyWordCountCallback = new AsyncCallback(WordCountCallback);
> /* Create new instance of the webservice that provides
> the required functionality*/
> GetWordCount=new localhost.ASPNetSuperheroService();
> GetWordCount.BeginWordCount(MyWordCountCallback,Ge tWordCount);
> }
>
> private void WordCountCallback(IAsyncResult Result)
> {
> // Call the webservice method in order to get current word count
> this.txtMessage.Text=GetWordCount.EndWordCount(Res ult);
> }
> }
>
>
> Regards,
>
> TC
>
>



 
Reply With Quote
 
 
 
 
TC
Guest
Posts: n/a
 
      05-06-2004
Hey folks,

I need C# assistance for non-blocking, asynch callback from the web page.

I am currently receiving the appropriate values back but the page does not
update.

Does anyone know why?

Regards,

TC


"avnrao" <(E-Mail Removed)> wrote in message
news:O$(E-Mail Removed)...
> if you are calling web service from an ASP.Net page on the server side,

you
> need wait till the call completes. use IAsynchResult.WaitHandle.WaitOne()
> check this if you need more info..
>

http://msdn.microsoft.com/library/de...ce09032002.asp
>
> Av.
> http://www.avnrao.blogspot.com
>
>
> "TC" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hello,
> >
> > I am making an asynchronous call to a webservice and trying to update

the
> > web page with the results.
> >
> > The page is not updating.
> >
> > Does anybody know why???
> >
> > Below is my code:
> >
> > public class ASPNetSuperhero : System.Web.UI.Page
> > {
> > protected System.Web.UI.WebControls.DropDownList drplstFilePaths;
> > protected System.Web.UI.WebControls.TextBox txtMessage;
> > protected System.Web.UI.WebControls.Button btnStartFileSearch;
> >
> > private localhost.ASPNetSuperheroService GetWordCount;
> > protected System.Web.UI.WebControls.Label lblWordCount;
> > private AsyncCallback MyWordCountCallback;
> >
> > private void Page_Load(object sender, System.EventArgs e)
> > {
> > // Put user code to initialize the page here
> > }
> >
> > #region Web Form Designer generated code
> > override protected void OnInit(EventArgs e)
> > {
> > //
> > // CODEGEN: This call is required by the ASP.NET Web Form Designer.
> > //
> > InitializeComponent();
> > base.OnInit(e);
> > }
> >
> > /// <summary>
> > /// Required method for Designer support - do not modify
> > /// the contents of this method with the code editor.
> > /// </summary>
> > private void InitializeComponent()
> > {
> > this.btnStartFileSearch.Click += new
> > System.EventHandler(this.btnStartFileSearch_Click) ;
> > this.Load += new System.EventHandler(this.Page_Load);
> >
> > }
> > #endregion
> >
> > private void btnStartFileSearch_Click(object sender, System.EventArgs

e)
> > {
> > MyWordCountCallback = new AsyncCallback(WordCountCallback);
> > /* Create new instance of the webservice that provides
> > the required functionality*/
> > GetWordCount=new localhost.ASPNetSuperheroService();
> > GetWordCount.BeginWordCount(MyWordCountCallback,Ge tWordCount);
> > }
> >
> > private void WordCountCallback(IAsyncResult Result)
> > {
> > // Call the webservice method in order to get current word count
> > this.txtMessage.Text=GetWordCount.EndWordCount(Res ult);
> > }
> > }
> >
> >
> > Regards,
> >
> > TC
> >
> >

>
>



 
Reply With Quote
 
[MSFT]
Guest
Posts: n/a
 
      05-06-2004
Hello,

ASP.NET application uses request/response architecture, and it may not be
suitable for asynchronous call to a web service. Regarding your code:

private void btnStartFileSearch_Click(object sender, System.EventArgs e)
{
MyWordCountCallback = new AsyncCallback(WordCountCallback);
/* Create new instance of the webservice that provides
the required functionality*/
GetWordCount=new localhost.ASPNetSuperheroService();
GetWordCount.BeginWordCount(MyWordCountCallback,Ge tWordCount);
}

After BeginWordCount, the response will be write back to client, won't wait
here. You have to use synchronous call here.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      05-06-2004
You initiate the call but don't wait for the result. The goal of an
asynchornous call is for example :
- make the call to a web service
- do some work
- get the result (will still wait if not already available)

That way you can do some work in parallel.

If you need the result from the webservice and you have nothing to do in
between making an asynchronous call is useless.

Patrice


"TC" <(E-Mail Removed)> a écrit dans le message de
news:(E-Mail Removed)...
> Hello,
>
> I am making an asynchronous call to a webservice and trying to update the
> web page with the results.
>
> The page is not updating.
>
> Does anybody know why???
>
> Below is my code:
>
> public class ASPNetSuperhero : System.Web.UI.Page
> {
> protected System.Web.UI.WebControls.DropDownList drplstFilePaths;
> protected System.Web.UI.WebControls.TextBox txtMessage;
> protected System.Web.UI.WebControls.Button btnStartFileSearch;
>
> private localhost.ASPNetSuperheroService GetWordCount;
> protected System.Web.UI.WebControls.Label lblWordCount;
> private AsyncCallback MyWordCountCallback;
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> }
>
> #region Web Form Designer generated code
> override protected void OnInit(EventArgs e)
> {
> //
> // CODEGEN: This call is required by the ASP.NET Web Form Designer.
> //
> InitializeComponent();
> base.OnInit(e);
> }
>
> /// <summary>
> /// Required method for Designer support - do not modify
> /// the contents of this method with the code editor.
> /// </summary>
> private void InitializeComponent()
> {
> this.btnStartFileSearch.Click += new
> System.EventHandler(this.btnStartFileSearch_Click) ;
> this.Load += new System.EventHandler(this.Page_Load);
>
> }
> #endregion
>
> private void btnStartFileSearch_Click(object sender, System.EventArgs e)
> {
> MyWordCountCallback = new AsyncCallback(WordCountCallback);
> /* Create new instance of the webservice that provides
> the required functionality*/
> GetWordCount=new localhost.ASPNetSuperheroService();
> GetWordCount.BeginWordCount(MyWordCountCallback,Ge tWordCount);
> }
>
> private void WordCountCallback(IAsyncResult Result)
> {
> // Call the webservice method in order to get current word count
> this.txtMessage.Text=GetWordCount.EndWordCount(Res ult);
> }
> }
>
>
> Regards,
>
> TC
>
>



 
Reply With Quote
 
TC
Guest
Posts: n/a
 
      05-06-2004
Actually, the idea would be to free up the GUI so that a user isn't stuck.
That makes an asynch call very useful. Then the user can do whatever work
they wish to and when the webservice returns the appropriate information,
the application can finish the work behind the scenes.

At least this is what I am trying to do.

Todd




"Patrice" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> You initiate the call but don't wait for the result. The goal of an
> asynchornous call is for example :
> - make the call to a web service
> - do some work
> - get the result (will still wait if not already available)
>
> That way you can do some work in parallel.
>
> If you need the result from the webservice and you have nothing to do in
> between making an asynchronous call is useless.
>
> Patrice
>
>
> "TC" <(E-Mail Removed)> a écrit dans le message de
> news:(E-Mail Removed)...
> > Hello,
> >
> > I am making an asynchronous call to a webservice and trying to update

the
> > web page with the results.
> >
> > The page is not updating.
> >
> > Does anybody know why???
> >
> > Below is my code:
> >
> > public class ASPNetSuperhero : System.Web.UI.Page
> > {
> > protected System.Web.UI.WebControls.DropDownList drplstFilePaths;
> > protected System.Web.UI.WebControls.TextBox txtMessage;
> > protected System.Web.UI.WebControls.Button btnStartFileSearch;
> >
> > private localhost.ASPNetSuperheroService GetWordCount;
> > protected System.Web.UI.WebControls.Label lblWordCount;
> > private AsyncCallback MyWordCountCallback;
> >
> > private void Page_Load(object sender, System.EventArgs e)
> > {
> > // Put user code to initialize the page here
> > }
> >
> > #region Web Form Designer generated code
> > override protected void OnInit(EventArgs e)
> > {
> > //
> > // CODEGEN: This call is required by the ASP.NET Web Form Designer.
> > //
> > InitializeComponent();
> > base.OnInit(e);
> > }
> >
> > /// <summary>
> > /// Required method for Designer support - do not modify
> > /// the contents of this method with the code editor.
> > /// </summary>
> > private void InitializeComponent()
> > {
> > this.btnStartFileSearch.Click += new
> > System.EventHandler(this.btnStartFileSearch_Click) ;
> > this.Load += new System.EventHandler(this.Page_Load);
> >
> > }
> > #endregion
> >
> > private void btnStartFileSearch_Click(object sender, System.EventArgs

e)
> > {
> > MyWordCountCallback = new AsyncCallback(WordCountCallback);
> > /* Create new instance of the webservice that provides
> > the required functionality*/
> > GetWordCount=new localhost.ASPNetSuperheroService();
> > GetWordCount.BeginWordCount(MyWordCountCallback,Ge tWordCount);
> > }
> >
> > private void WordCountCallback(IAsyncResult Result)
> > {
> > // Call the webservice method in order to get current word count
> > this.txtMessage.Text=GetWordCount.EndWordCount(Res ult);
> > }
> > }
> >
> >
> > Regards,
> >
> > TC
> >
> >

>
>



 
Reply With Quote
 
John Saunders
Guest
Posts: n/a
 
      05-06-2004
"TC" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I am making an asynchronous call to a webservice and trying to update the
> web page with the results.
>
> The page is not updating.
>
> Does anybody know why???


Yes. Your page does not exist when your callback is called.

> private void WordCountCallback(IAsyncResult Result)
> {
> // Call the webservice method in order to get current word count
> this.txtMessage.Text=GetWordCount.EndWordCount(Res ult);
> }
> }


When this method is called back, the request has already completed, the
response has already been sent to the client, and you are out of luck.

I recommend that you find some sample code which does this and follow that
example. I can recommend it because you're not going to find any such sample
code - the entire idea is contrary to the way that ASP.NET works.

See
http://msdn.microsoft.com/library/de...singstages.asp.
--
John Saunders
John.Saunders at SurfControl.com



 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      05-07-2004
Humm. Sorry if I restate something ovbious...

The page the user sees is just some HTML that is rendered by the server side
APSX page. Once the ASPX page is finished the user see client side HTML code
and the page doesn't exist any more server side. You nedd then another HTTP
request to be in touch again with server side code.

I see basically two options :

- you need the webservice call to be completed to have a meaningfull page :
- out of luck, needs to wait the result from the webservice to construct
the final HTML page
- use an IFRAME that calls an ASPX page that calls this webservice. The
user can see a part of the final UI (done by the main ASPX page) but will
have still to wait a bit to see the inner frame content(done be the ASPX
page referenced by the IFRAME). Of course, if the webservice is quite
qucik,, the first optino is probably still the simpler.

- you don't need the webservice call to be completed (will be used sometimes
later)
- you could queue these calls to have them done seperately from the user
page (AFAIK .NET proivides something along these lines was called MSMQ
previously)

Do you recognize a case in which you are ?

Patrice


"TC" <(E-Mail Removed)> a écrit dans le message de
news:(E-Mail Removed)...
> Actually, the idea would be to free up the GUI so that a user isn't stuck.
> That makes an asynch call very useful. Then the user can do whatever work
> they wish to and when the webservice returns the appropriate information,
> the application can finish the work behind the scenes.
>
> At least this is what I am trying to do.
>
> Todd
>
>
>
>
> "Patrice" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > You initiate the call but don't wait for the result. The goal of an
> > asynchornous call is for example :
> > - make the call to a web service
> > - do some work
> > - get the result (will still wait if not already available)
> >
> > That way you can do some work in parallel.
> >
> > If you need the result from the webservice and you have nothing to do in
> > between making an asynchronous call is useless.
> >
> > Patrice
> >
> >
> > "TC" <(E-Mail Removed)> a écrit dans le message de
> > news:(E-Mail Removed)...
> > > Hello,
> > >
> > > I am making an asynchronous call to a webservice and trying to update

> the
> > > web page with the results.
> > >
> > > The page is not updating.
> > >
> > > Does anybody know why???
> > >
> > > Below is my code:
> > >
> > > public class ASPNetSuperhero : System.Web.UI.Page
> > > {
> > > protected System.Web.UI.WebControls.DropDownList drplstFilePaths;
> > > protected System.Web.UI.WebControls.TextBox txtMessage;
> > > protected System.Web.UI.WebControls.Button btnStartFileSearch;
> > >
> > > private localhost.ASPNetSuperheroService GetWordCount;
> > > protected System.Web.UI.WebControls.Label lblWordCount;
> > > private AsyncCallback MyWordCountCallback;
> > >
> > > private void Page_Load(object sender, System.EventArgs e)
> > > {
> > > // Put user code to initialize the page here
> > > }
> > >
> > > #region Web Form Designer generated code
> > > override protected void OnInit(EventArgs e)
> > > {
> > > //
> > > // CODEGEN: This call is required by the ASP.NET Web Form Designer.
> > > //
> > > InitializeComponent();
> > > base.OnInit(e);
> > > }
> > >
> > > /// <summary>
> > > /// Required method for Designer support - do not modify
> > > /// the contents of this method with the code editor.
> > > /// </summary>
> > > private void InitializeComponent()
> > > {
> > > this.btnStartFileSearch.Click += new
> > > System.EventHandler(this.btnStartFileSearch_Click) ;
> > > this.Load += new System.EventHandler(this.Page_Load);
> > >
> > > }
> > > #endregion
> > >
> > > private void btnStartFileSearch_Click(object sender,

System.EventArgs
> e)
> > > {
> > > MyWordCountCallback = new AsyncCallback(WordCountCallback);
> > > /* Create new instance of the webservice that provides
> > > the required functionality*/
> > > GetWordCount=new localhost.ASPNetSuperheroService();
> > > GetWordCount.BeginWordCount(MyWordCountCallback,Ge tWordCount);
> > > }
> > >
> > > private void WordCountCallback(IAsyncResult Result)
> > > {
> > > // Call the webservice method in order to get current word count
> > > this.txtMessage.Text=GetWordCount.EndWordCount(Res ult);
> > > }
> > > }
> > >
> > >
> > > Regards,
> > >
> > > TC
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
TC
Guest
Posts: n/a
 
      05-10-2004
Hey Folks,

Thanks for the help!

Basically, because what I wish to do is contrary to the way in which ASP
works, I'm just gonna wait for the response to return.

Thanks Again,

TC



"Patrice" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Humm. Sorry if I restate something ovbious...
>
> The page the user sees is just some HTML that is rendered by the server

side
> APSX page. Once the ASPX page is finished the user see client side HTML

code
> and the page doesn't exist any more server side. You nedd then another

HTTP
> request to be in touch again with server side code.
>
> I see basically two options :
>
> - you need the webservice call to be completed to have a meaningfull page

:
> - out of luck, needs to wait the result from the webservice to

construct
> the final HTML page
> - use an IFRAME that calls an ASPX page that calls this webservice.

The
> user can see a part of the final UI (done by the main ASPX page) but will
> have still to wait a bit to see the inner frame content(done be the ASPX
> page referenced by the IFRAME). Of course, if the webservice is quite
> qucik,, the first optino is probably still the simpler.
>
> - you don't need the webservice call to be completed (will be used

sometimes
> later)
> - you could queue these calls to have them done seperately from the

user
> page (AFAIK .NET proivides something along these lines was called MSMQ
> previously)
>
> Do you recognize a case in which you are ?
>
> Patrice
>
>
> "TC" <(E-Mail Removed)> a écrit dans le message de
> news:(E-Mail Removed)...
> > Actually, the idea would be to free up the GUI so that a user isn't

stuck.
> > That makes an asynch call very useful. Then the user can do whatever

work
> > they wish to and when the webservice returns the appropriate

information,
> > the application can finish the work behind the scenes.
> >
> > At least this is what I am trying to do.
> >
> > Todd
> >
> >
> >
> >
> > "Patrice" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > You initiate the call but don't wait for the result. The goal of an
> > > asynchornous call is for example :
> > > - make the call to a web service
> > > - do some work
> > > - get the result (will still wait if not already available)
> > >
> > > That way you can do some work in parallel.
> > >
> > > If you need the result from the webservice and you have nothing to do

in
> > > between making an asynchronous call is useless.
> > >
> > > Patrice
> > >
> > >
> > > "TC" <(E-Mail Removed)> a écrit dans le message de
> > > news:(E-Mail Removed)...
> > > > Hello,
> > > >
> > > > I am making an asynchronous call to a webservice and trying to

update
> > the
> > > > web page with the results.
> > > >
> > > > The page is not updating.
> > > >
> > > > Does anybody know why???
> > > >
> > > > Below is my code:
> > > >
> > > > public class ASPNetSuperhero : System.Web.UI.Page
> > > > {
> > > > protected System.Web.UI.WebControls.DropDownList drplstFilePaths;
> > > > protected System.Web.UI.WebControls.TextBox txtMessage;
> > > > protected System.Web.UI.WebControls.Button btnStartFileSearch;
> > > >
> > > > private localhost.ASPNetSuperheroService GetWordCount;
> > > > protected System.Web.UI.WebControls.Label lblWordCount;
> > > > private AsyncCallback MyWordCountCallback;
> > > >
> > > > private void Page_Load(object sender, System.EventArgs e)
> > > > {
> > > > // Put user code to initialize the page here
> > > > }
> > > >
> > > > #region Web Form Designer generated code
> > > > override protected void OnInit(EventArgs e)
> > > > {
> > > > //
> > > > // CODEGEN: This call is required by the ASP.NET Web Form

Designer.
> > > > //
> > > > InitializeComponent();
> > > > base.OnInit(e);
> > > > }
> > > >
> > > > /// <summary>
> > > > /// Required method for Designer support - do not modify
> > > > /// the contents of this method with the code editor.
> > > > /// </summary>
> > > > private void InitializeComponent()
> > > > {
> > > > this.btnStartFileSearch.Click += new
> > > > System.EventHandler(this.btnStartFileSearch_Click) ;
> > > > this.Load += new System.EventHandler(this.Page_Load);
> > > >
> > > > }
> > > > #endregion
> > > >
> > > > private void btnStartFileSearch_Click(object sender,

> System.EventArgs
> > e)
> > > > {
> > > > MyWordCountCallback = new AsyncCallback(WordCountCallback);
> > > > /* Create new instance of the webservice that provides
> > > > the required functionality*/
> > > > GetWordCount=new localhost.ASPNetSuperheroService();
> > > > GetWordCount.BeginWordCount(MyWordCountCallback,Ge tWordCount);
> > > > }
> > > >
> > > > private void WordCountCallback(IAsyncResult Result)
> > > > {
> > > > // Call the webservice method in order to get current word count
> > > > this.txtMessage.Text=GetWordCount.EndWordCount(Res ult);
> > > > }
> > > > }
> > > >
> > > >
> > > > Regards,
> > > >
> > > > TC
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
asynchronous callback component =?Utf-8?B?Q0xFQVItUkNJQw==?= ASP .Net 3 04-19-2007 09:28 PM
asynchronous callback component CLEAR-RCIC ASP General 2 04-03-2007 01:10 PM
Organizing asynchronous web-service and callback using SoapClient dzeaman ASP .Net Web Services 0 12-24-2005 10:16 AM
asynchronous, callback, dropdownlist, v2.0 Alexander Widera ASP .Net 2 12-15-2005 01:13 PM
Asynchronous WebService Callback to Force Postback =?Utf-8?B?R3JpZ3M=?= ASP .Net 3 12-11-2004 01:30 AM



Advertisments