trying to save 400 MB or more large video, while convert memory stream to Bytearray then the app shows a black screen and get terminated. cant able catches the exception even though try-catch placed inside the code. how to catch the exception and resolves the issue.
public Byte[] StreamToByteArray(Stream stream)
{
try
{
byte[] bytes = new byte[16384];
using (MemoryStream ms = new MemoryStream())
{
int count = 0;
while ((count = stream.Read(bytes, 0, bytes.Length)) > 0)
{
ms.Write(bytes, 0, count);
}
return ms.ToArray();
}
}
catch (Exception Ex)
{
return null;
}
}
output window message
Explicit concurrent copying GC freed 12(31KB) AllocSpace objects, 0(0B) LOS objects, 50% free, 1902KB/3MB, paused 168us total 57.118ms 02-19 14:52:46.566 D/Mono ( 2628): GC_TAR_BRIDGE bridges 83 objects 88 opaque 6 colors 83 colors-bridged 83 colors-visible 83 xref 0 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.18ms tarjan 0.19ms scc-setup 0.18ms gather-xref 0.01ms xref-setup 0.00ms cleanup 0.07ms 02-19 14:52:46.566 D/Mono ( 2628): GC_BRIDGE: Complete, was running for 60.96ms 02-19 14:52:46.566 D/Mono ( 2628): GC_MAJOR_CONCURRENT_FINISH: (finishing) time 15962.01ms, stw 172.92ms los size: 1573896K in use: 1573042K 02-19 14:52:46.566 D/Mono ( 2628): GC_MAJOR_SWEEP: major size: 1936K in use: 972K [HotReload] (2021-02-19 14:52:40.9): INFO: (Sample.Android) Stopped Hot Reload session due to ExplicitlyEnded ...