Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>9.0.0</Version>
<Version>9.0.1</Version>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -20,6 +20,6 @@

<ItemGroup>
<Using Include="BootstrapBlazor.Components" />
</ItemGroup>
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions src/components/BootstrapBlazor.PdfReader/PdfReader.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,25 +321,25 @@ public virtual async Task ShowPdf(string localFileName)
/// </summary>
/// <param name="stream"></param>
/// <param name="forceLoad">default true</param>
/// <param name="islocalFile"></param>
/// <param name="isLocalFile"></param>
/// <returns></returns>
public virtual async Task ShowPdf(Stream stream, bool forceLoad = true, bool islocalFile = false)
public virtual async Task ShowPdf(Stream stream, bool forceLoad = true, bool isLocalFile = false)
{
if (Module == null)
{
Stream = stream;
}
else if (islocalFile)
else if (isLocalFile)
{
if (forceLoad)
{
streamCache = new byte[stream.Length];
stream.Read(streamCache, 0, (int)stream.Length);
_ = stream.Read(streamCache, 0, (int)stream.Length);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): Consider using an asynchronous read operation.

Replace stream.Read with await stream.ReadAsync(...) in this async method to avoid blocking on large data.

Suggested implementation:

                await stream.ReadAsync(streamCache, 0, (int)stream.Length);
                await stream.ReadAsync(streamCache, 0, (int)stream.Length);

Make sure the method containing this code is marked as async and returns Task or Task as appropriate. Also, update any callers of the method to properly await its result.

}
if (streamCache == null)
{
streamCache = new byte[stream.Length];
stream.Read(streamCache, 0, (int)stream.Length);
_ = stream.Read(streamCache, 0, (int)stream.Length);
}
if (streamCache != null)
{
Expand Down