So I have this function that takes a function with no parameters:
public static bool RetryUntilSuccessOrTimeout(Func<bool> task, TimeSpan timeSpan)
{
bool success = false;
int elapsed = 0;
while ((!success) && (elapsed < timeSpan.TotalMilliseconds))
{
Thread.Sleep(1000);
elapsed += 1000;
success = task();
}
return success;
}
And then I have a bunch of functions like:
private static bool OnDeleted(object source, FileSystemEventArgs e){...}
private static bool OnChanged(object source, FileSystemEventArgs e){...}
private static bool OnCreated(object source, FileSystemEventArgs e){...}
I have a function that takes same aruments as those three. So I have that information provided. Is there a way to pass these function as ones not taking any arguments (because I provide them) so i can pass it into the "task" of RetryUntilSuccessOrTimeout() ?
An encapsulating image of the problem: