I am using the PCL Storage library in a Xamarin (UWP, Android, iOS) project for platform-independent file system access.
In order to prevent two threads accessing the same file at the same time, and thus throwing an exception, I was planning to use the C# lock
statement.
However, this Microsoft Doc states that it is not possible to use the await
keyword inside a lock
statement.
Since PCL Storage is all async
methods and can hardly be used without await
, I am looking for either a way to get lock
and await
to work together, or an alternative, simple method to handle concurrent file access.
Thank you for any advice. Please bear in mind that I am restricted to .NET Core.
Chris.