Method Rent
Rent(string)
Temporarily rents the resource for the specified reason.
Declaration
IDisposable Rent(string reason)
Parameters
| Type | Name | Description |
|---|---|---|
| string | reason | The reason for renting the resource. |
Returns
| Type | Description |
|---|---|
| IDisposable | An anchor which must be disposed as soon as the resource is no longer needed. Disposing the anchor releases the rental for the specified reason. |
Examples
This example demonstrates how to rent and release the resource for a specific reason.
var manager = new SharedResourceRentManager();
IDisposable rental = manager.Rent("Task B");
// The resource is now rented for Task B.
rental.Dispose();
// The resource is no longer rented for Task B.