private void PackUriResourceHandler_ReadResponse(object sender, CfxReadResponseEventArgs readResponse) { if (_StreamResourceInfo == null) { readResponse.SetReturnValue(false); return; } var buffer = new byte[readResponse.BytesToRead]; var bytesRead = _StreamResourceInfo.Stream.Read(buffer, 0, readResponse.BytesToRead); System.Runtime.InteropServices.Marshal.Copy(buffer, 0, readResponse.DataOut, bytesRead); readResponse.BytesRead = bytesRead; readResponse.SetReturnValue(bytesRead > 0); }
void ResourceHandler_ReadResponse(object sender, CfxReadResponseEventArgs e) { int bytesToCopy = webResource.data.Length - bytesDone; if (bytesToCopy > e.BytesToRead) { bytesToCopy = e.BytesToRead; } Marshal.Copy(webResource.data, bytesDone, e.DataOut, bytesToCopy); e.BytesRead = bytesToCopy; bytesDone += bytesToCopy; e.SetReturnValue(true); }
private void PackUriResourceHandler_ReadResponse(object sender, CfxReadResponseEventArgs readResponse) { if (_StreamResourceInfo == null) { readResponse.SetReturnValue(false); return; } var stream = _StreamResourceInfo.Stream; var buffer = new byte[readResponse.BytesToRead]; var bytesRead = stream.Read(buffer, 0, readResponse.BytesToRead); System.Runtime.InteropServices.Marshal.Copy(buffer, 0, readResponse.DataOut, bytesRead); readResponse.BytesRead = bytesRead; readResponse.SetReturnValue(true); if (stream.Position != stream.Length) { return; } Clean(); _Logger?.Info(Loaded); }
private void OnReadResponse(object sender, CfxReadResponseEventArgs e) { int bytesToCopy = data.Length - readResponseStreamOffset; if (bytesToCopy > e.BytesToRead) { bytesToCopy = e.BytesToRead; } Marshal.Copy(data, readResponseStreamOffset, e.DataOut, bytesToCopy); e.BytesRead = bytesToCopy; readResponseStreamOffset += bytesToCopy; e.SetReturnValue(true); if (readResponseStreamOffset == data.Length) { gcHandle.Free(); } }