Parallel reading of regionfiles.

This commit is contained in:
glax 2023-04-21 11:40:15 +02:00
parent 93a448e189
commit 7d769a064f

View File

@ -40,20 +40,10 @@ namespace Pathfinding
if (!File.Exists(filePath))
return null;
while (true)
{
try
{
FileStream regionFile = new (filePath, FileMode.Open);
Region retRegion = JsonSerializer.Deserialize<Region>(regionFile, Region.serializerOptions)!;
regionFile.Dispose();
return retRegion;
}catch(IOException)
{
Thread.Sleep(10);
}
}
FileStream regionFile = new (filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
Region retRegion = JsonSerializer.Deserialize<Region>(regionFile, Region.serializerOptions)!;
regionFile.Dispose();
return retRegion;
}
private Region? RegionFromId(ulong regionId)