Long latency when creating a new FileStream...

  • Thread starter Thread starter hzgt9b
  • Start date Start date
H

hzgt9b

Using VS2005, VB.NET,
I have a multi-threaded application. In one of my threads I need to
read a file as a binary stream. I am able to accomplish this using the
following code:

1 Dim BinaryFile As FileStream = New FileStream(<some file name>,
FileMode.Open, FileAccess.Read, FileShare.Read)
2 Dim BinRead As BinaryReader = Nothing
3 Me.BinRead = New BinaryReader(BinaryFile)
4 Me.BinRead.BaseStream.Seek(0, SeekOrigin.Begin)
5 Me.BinBytes = Me.BinRead.ReadBytes(<number of bytes to read>)

The code above works for me save one issue: on the first execution,
line 1 takes a really long time (4-7 seconds) to execute and don't
have any idea why.

Anyone have an idea what could be causing this latency and how to
avoid it?

Thanks for your attention to this...
 
Using VS2005, VB.NET,
I have a multi-threaded application. In one of my threads I need to
read a file as a binary stream. I am able to accomplish this using the
following code:

1 Dim BinaryFile As FileStream = New FileStream(<some file name>,
FileMode.Open, FileAccess.Read, FileShare.Read)
2 Dim BinRead As BinaryReader = Nothing
3 Me.BinRead = New BinaryReader(BinaryFile)
4 Me.BinRead.BaseStream.Seek(0, SeekOrigin.Begin)
5 Me.BinBytes = Me.BinRead.ReadBytes(<number of bytes to read>)

The code above works for me save one issue: on the first execution,
line 1 takes a really long time (4-7 seconds) to execute and don't
have any idea why.

Anyone have an idea what could be causing this latency and how to
avoid it?

Thanks for your attention to this...

I believe that I figured this out - the latency is dependent on the
file size - I was testing with really large files thus getting a long
wait...
 
Back
Top