Trying to find the most elegant solution for a situation when I get a "IOException: Sharing violation" on loading a JSON file because it is being saved at the same time by another application.
Using a "try Catch' with some form of recursion when loading, though inelegant, makes sense. So after searching came across this C# solution which gets a lot of up votes Cleanest way to write retry logic?
The actual function call where my load occurs is
private static T LoadData<T>(string filePath)
{
return JsonUtility.FromJson<T>(File.ReadAllText(filePath));
}
However not sure how to implement using the above linked solution (Retry.Do) which doesn't seem to allow passed arguments in the function call ie
Retry.Do(SomeFunctionThatCanFail, TimeSpan.FromSeconds(1));
Can anyone help?