Method NewAnonymous
NewAnonymous<T>(Lock, Int32, Func<T>)
Creates a new instance with the ability to specify the DoBody() method
through the doBody
argument
Simple example:
var result = Lock.With.NewAnonymous<string>(
@lock: directory.MakeLock("my.lock"),
lockWaitTimeout: Lock.LOCK_OBTAIN_WAIT_FOREVER,
doBody: () =>
{
//... code to execute while locked ...
return "the result";
}).Run();
The result of the operation is the value that is returned from doBody
(i.e. () => { return "the result"; }). The type of
Declaration
public static Lock.With<T> NewAnonymous<T>(Lock lock, int lockWaitTimeout, Func<T> doBody)
Parameters
Type | Name | Description |
---|---|---|
Lock | lock | the Lock instance to use |
System.Int32 | lockWaitTimeout | length of time to wait in milliseconds or LOCK_OBTAIN_WAIT_FOREVER to retry forever |
Func<T> | doBody | a delegate method that |
Returns
Type | Description |
---|---|
Lock.With<T> | The value that is returned from the |
Type Parameters
Name | Description |
---|---|
T |