I know there are a lot of alternatives out there where we can pass a Func through the parameter and call it from inside the body method.
My issue expands on this a little more. I have a DataTable with a ReaderWriterLock and want to centralize where I am doing the locking. My idea is to have a method that accepts a lambda, and from there I can do something like this.
public void processLambda(some lambda/callback param) {
readWriteLock.acquireWriteLock(-1);
try {
// execute method here, which may write to the datatable.
} finally {
readWriteLock.releaseWriteLock();
}
}
How should I go about this? I do not know ahead of time what type of parameters this method will have.