473,385 Members | 1,356 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,385 software developers and data experts.

Aync WebClient

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

Sep 27 '07 #1
1 1273
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
Sep 27 '07 #2

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

Similar topics

11
by: ptass | last post by:
Hi I've installed win2k3 sp1 on a machine where an openRead on any given file was previously working. After installation, I get a webException as follows... ..message "An exception occurred...
3
by: Ram Baruch | last post by:
Hi, I'm trying to use WebClient class to upload data. In order to upload it, I need to use my username and password. Does somebody know how can I set it in the WebClient class? Regards, Ram.
2
by: xzzy | last post by:
I have .net 1.1 c# . . . . . using System.Net only lists sockets what do I need to do to be able to do: using System.Net.WebClient;
6
by: A.M-SG | last post by:
Hi, I have an aspx page at the web server that provides PDF documents for smart client applications. Here is the code in aspx page that defines content type: Response.ContentType =...
6
by: Giovanni | last post by:
Hi Guys, Really strange problem I am experiencing... I have setup a virtual directory with Read Only permissions on an ISA/IIS server (SBS 2003). In that virt. dir., I placed 1 file...
1
by: vin.dor | last post by:
Dear All, I am using WebClient in my Visual Studio .Net 2003 project to download an image from the Internet. The following is my function: C# Code: public static bool downloadFile(string...
4
by: Lehel Kovach | last post by:
I'm having a problem with the WebClient object. When I post data to certain sites, it will receive a command from the webserver (object moved) and continue to the next link by downloading that. ...
1
by: Mad Scientist Jr | last post by:
For some reason I can't get a WebClient to access an outside URL from behind our firewall. The code works when it runs outside the firewall. I turned on windows authentication in the web.config...
1
by: Mike | last post by:
I am using PowerShell to download an XML file into a string using the DownloadString(URI) method of System.Net.WebClient object. Sample commands below: $Result = $Null; $WebClient = new-object...
2
by: MichaelSchoeler | last post by:
Hi, I'm having problems with the WebClient class regarding UTF-8 encoded data. When I access a specific webservice directly I can see the data arrives in corretly formatted UTF-8. But when I...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.