PC Review


Reply
Thread Tools Rate Thread

Aync WebClient

 
 
sandrofurlan
Guest
Posts: n/a
 
      27th Sep 2007
Hi all,
I'm a newbie about asp.net.

I've a web client that call in async mode one webservice method
The problem is that I don't know how to refresh control text property.

Some code:

Protected Sub ServiceCallback(ByVal ar As IAsyncResult)
Dim client As ServiceClient = ar.AsyncState
Dim e As ServiceEventArgs = client.EndWaitEvent(ar)
If e.Status = 4 Then
Label1.text = "result OK" <----
Else
Label1.text = "result False" <----
End If
' reload callback handler
Dim callBack As New AsyncCallback(AddressOf ServiceCallback)
client.BeginWaitEvent(callBack, client)
End Sub

Protected Sub form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles form1.Load
Dim client As New ServiceClient
Label1.Text = "Open" & client.StartService()
Dim callBack As New AsyncCallback(AddressOf ServiceCallback)
Dim Iar As IAsyncResult = client.BeginWaitEvent(callBack,
client)
End Sub

The problem is that label1.text could not change.

Some idea?
Thanks,

Sandro Furlan

 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      27th Sep 2007
an asp.net page just builds html and sends it to the browser, its not
connected the simple cycle is

1) start request
2) create page class instance
3) call page events
4) return html
5) end request

you are updating the server control after the web request is completed.
the fix is in formload or prerender add a wait until the async call
completes, then continue the page processing.

-- bruce (sqlwork.com)

sandrofurlan wrote:
> Hi all,
> I'm a newbie about asp.net.
>
> I've a web client that call in async mode one webservice method
> The problem is that I don't know how to refresh control text property.
>
> Some code:
>
> Protected Sub ServiceCallback(ByVal ar As IAsyncResult)
> Dim client As ServiceClient = ar.AsyncState
> Dim e As ServiceEventArgs = client.EndWaitEvent(ar)
> If e.Status = 4 Then
> Label1.text = "result OK" <----
> Else
> Label1.text = "result False" <----
> End If
> ' reload callback handler
> Dim callBack As New AsyncCallback(AddressOf ServiceCallback)
> client.BeginWaitEvent(callBack, client)
> End Sub
>
> Protected Sub form1_Load(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles form1.Load
> Dim client As New ServiceClient
> Label1.Text = "Open" & client.StartService()
> Dim callBack As New AsyncCallback(AddressOf ServiceCallback)
> Dim Iar As IAsyncResult = client.BeginWaitEvent(callBack,
> client)
> End Sub
>
> The problem is that label1.text could not change.
>
> Some idea?
> Thanks,
>
> Sandro Furlan
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Help with Webclient.dll Soapm Windows XP General 2 10th Oct 2004 04:24 PM
WebClient Peter Microsoft VB .NET 3 25th Apr 2004 09:42 PM
WebClient Alan Microsoft C# .NET 0 19th Feb 2004 02:26 PM
WebClient DownloadFile gets ALL files in directory?!? WebClient bug? Jeremy Microsoft Dot NET Framework 1 10th Nov 2003 01:10 PM
WebClient Arash Microsoft C# .NET 2 17th Sep 2003 02:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:57 AM.