How can I access the data retrieved using WebClient.DownloadDataAsync?
(This is the next question of this .
I want to read an endless audio stream asynchronously so that I can perform my JIT analysis on the received data. Using the WebClient
object method DownloadDataAsync
I can load the upload easily, see the following Win form project:
Imports System.Net 'For WebClient
Public Class Form1
Private WithEvents c As New WebClient()
Protected Overrides Sub Finalize()
c.Dispose()
MyBase.Finalize()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim u As New Uri("http://flower.serverhostingcenter.com:8433/;")
c.DownloadDataAsync(u)
End Sub
Private Sub c_DownloadProgressChanged(sender As Object, e As DownloadProgressChangedEventArgs) Handles c.DownloadProgressChanged
Debug.Print(e.BytesReceived.ToString & " B received.")
End Sub
End Class
and the stream seems to flow by event DownloadProgressChanged
to the nearest window:
2920 B received.
48180 B received.
56940 B received.
61320 B received.
87600 B received.
94900 B received.
160436 B received.
162060 B received.
227596 B received.
...
However, I am missing a method to read the received data as well . Since this is an endless stream, it DownloadDataCompleted
will never fire (and there will be no other event other than the one in use).
How to get access to the received data?
source to share