-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Description
Description
FileStreams opened with isAsync: true fails to perform asynchronous read operations. Not specifying isAsync: true runs completely fine.
The function used to get a FileStream:
private void InitializeFileStream(string filePath, bool exclusive, int readSize, int writeSize)
{
FileAccess access = 0;
if (readSize > 0)
access |= FileAccess.Read;
if (writeSize > 0)
access |= FileAccess.Write;
FileShare share = exclusive ? FileShare.None : (FileShare)access;
FileStream = new FileStream(filePath, FileMode.Open, access, share, Math.Max(readSize, writeSize), true);
}Run loop of the task:
private async void ReadPoll()
{
while (_run)
{
int bytesReturned = await FileStream!.ReadAsync(_readBuffer);
OnInput(_readBuffer.Slice(0, bytesReturned));
}
}Configuration
| OS Version | Windows 10 21H1 |
|---|---|
| .NET Version | .NET 6 preview 4 |
Regression?
I'm not sure...
Other information
Exception has occurred: CLR/System.IO.IOException
An exception of type 'System.IO.IOException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'Incorrect function. : '\\?\hid#vid_28bd&pid_0906&mi_02#7&194ad48b&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}''
at System.IO.Strategies.FileStreamHelpers.GetFileLength(SafeFileHandle handle, String path)
at System.IO.Strategies.WindowsFileStreamStrategy.get_Length()
at System.IO.Strategies.AsyncWindowsFileStreamStrategy.ReadAsyncInternal(Memory`1 destination, CancellationToken cancellationToken)
at System.IO.Strategies.AsyncWindowsFileStreamStrategy.ReadAsync(Memory`1 destination, CancellationToken cancellationToken)
at System.IO.Strategies.BufferedFileStreamStrategy.ReadAsync(Memory`1 buffer, CancellationToken cancellationToken)
at System.IO.FileStream.ReadAsync(Memory`1 buffer, CancellationToken cancellationToken)
The source repo is currently private, but if more information or testing is needed from my side then I'll do it willingly.