[IronPython] No OpenReadCompleted Event for WebClient in Silverlight 2
Michael Foord
fuzzyman at gmail.com
Wed Mar 12 21:18:26 CET 2008
The correct thing to do is [to not follow the example in the
Silverlight docs, but instead] either use:
web = WebClient()
web.DownloadStringCompleted += completed
web.DownloadStringAsync(uri)
*or*
web = WebClient()
web.OpenReadCompleted += completed
web.OpenReadAsync(uri)
Depending on whether you want to fetch a server resource as a string
or as a stream. :-)
Michael
http://www.manning.com/foord
On Mar 11, 11:17 pm, Michael Foord <fuzzy... at voidspace.org.uk> wrote:
> Hello guys,
>
> With the following code executed in Silverlight2 I find I get the
> 'DownloadProgressChanged' event fired 3 times and the
> 'OpenReadCompleted' not at all. :-(
>
> The changed event shows 100% completed every time it is fired...
>
> from System import Uri, UriKind
> from System.Net import WebClient
>
> uri = Uri('/', UriKind.Relative)
> web = WebClient()
>
> def completed(s, e):
> print 'Completed'
> print e.Error
> print e.Cancelled
> print e.Result
>
> def changed(s, e):
> print 'Bytes Recieved', e.BytesReceived
> print 'Progress Percentage', e.ProgressPercentage
>
> web.OpenReadCompleted += completed
> web.DownloadProgressChanged += changed
> web.DownloadStringAsync(uri)
>
> Anyone got any clues?
>
> Thanks
>
> Michaelhttp://www.manning.com/foord
> _______________________________________________
> Users mailing list
> Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com
More information about the Ironpython-users
mailing list