[mono-vb] Mono Hangs on Using streamResponse As Stream = request.EndGetRequestStream(result)

Easy_Rider9999 jhmgbl2 at t-online.de
Sun Jan 2 08:16:47 EST 2011


This is the code:
<code>
 ''' <summary>
  ''' Submit data asynchronously
  ''' </summary>
  ''' 
  Private Sub ReadCallback(ByVal result As IAsyncResult)
    Const CodeLoc As String = ClassName & ".ReadCallBack"
    gStatus = CodeLoc & " Start"
    Dim state As RequestState = DirectCast(result.AsyncState, RequestState)
    Dim request As WebRequest = state.request

    ' End the Asynchronus request.
    gStatus = CodeLoc & " EndGetRequestStream"
    Using streamResponse As Stream = request.EndGetRequestStream(result)
      ' Submit content
      If state.content IsNot Nothing Then
        gStatus = CodeLoc & " streamResponse.Write"
        streamResponse.Write(state.content, 0, state.content.Length)
      Else
        gStatus = CodeLoc & " New FileStream uploadFilePath = " &
state.uploadFilePath
        Using fs As New FileStream(state.uploadFilePath, FileMode.Open,
FileAccess.Read)
          Dim content As Byte() = New Byte(4095) {}
          Dim bytesRead As Integer = 0
          Do
            gStatus = CodeLoc & " Read"
            bytesRead = fs.Read(content, 0, content.Length)
            streamResponse.Write(content, 0, bytesRead)

            'XXX: perform upload status callback
          Loop While bytesRead > 0
        End Using
      End If
    End Using
    gStatus = CodeLoc & " BeginGetResponse"
    ' Done, invoke user callback
    request.BeginGetResponse(state.userCallback, state.userState)
  End Sub
</code>


Regards 

Hans
-- 
View this message in context: http://mono.1490590.n4.nabble.com/Mono-Hangs-on-Using-streamResponse-As-Stream-request-EndGetRequestStream-result-tp3170875p3170875.html
Sent from the Mono - VB mailing list archive at Nabble.com.


More information about the Mono-vb mailing list