silverlight - How to use OpenReadAsync and WebClient to download data and assign to UserToken? -


I need to be able to partially use webmail, let me download an image as a byte stream And it needs to be allocated for an image, more than one image and items have to be assigned, and it will appear in a list. This application is a Silverlight 3 application, which should be the solution that works in Silverlight.

I have a download method that I would like to use:

  Public sub-download (as ur as source, by-tail target as a bitmap image ) Turn down the new webclick _Client.OpenReadAsync source, target) as the _Client AddHandler _Client.OpenRead full, address Download Download End End sub  

Here is the downloaded event handler (Partial Implementation) , ToByteArray method to convert downloaded image data to array Abuse does byte.

  Private was downloaded (as an object, as a sender, ByWorld as the Open Read Integrated Accent Agency) If E. If not canceled then dim byte (byte) = ToByteArray (e.Result) Dim Bitmap New as Dim Bitmap Image Bitmap SetSource (e.Result) 'Set Target Bitmap End Here If End All  

The target image that is set on the downloaded image (target) is passed as userToken; OpenReadAsync method, and can be read using E. OpenReadCompletedEventArgs UserState property, although it only reads Is - download me inside the downloaded method The image went targets need to be set.

Image source / bitmap image can be passed as a UserToken in the download method, which can be set in the downloaded method?

I will organize this code like this: -

  Download Public Function (URI as Uri Source) BitmapImage Client as BitmapImage Smim Client as New Webclient Slow Target OpenRaidSync (Source, Target) AddHandler Client OpenRed complete, addressoff downloaded target goal completion downloaded sub-private sub (as an object, as an object by the sender, as the open-read integrated entente) if e. If not canceled, then the Direct Seas (E. UserState, Bitmap Image). Setsers (E. Result) End And End  

Note calling will be: -

  myBitmap = Download (myUri)  

After completing the sourc download, the bitmap will return e-mails.

ToByteArray did not appear to serve any purpose, so I removed it. I have also removed ByRef passing.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -