It depends on what you need to do inside the method, however usually a technique called CompareAndSwap can be used. The .NET framework uses the CompareExchange function. In any case you have to check if you can express your lock in a way that is suitable for CAS.
More Related Contents:
- How to convert this code to LINQ [closed]
- How to return a file (FileContentResult) in ASP.NET WebAPI
- Most efficient way to test equality of lambda expressions
- Avoiding first chance exception messages when the exception is safely handled
- Reliably stop System.Threading.Timer?
- Log4Net: Programmatically specify multiple loggers (with multiple file appenders)
- The ‘Microsoft.ACE.OLEDB.12.0’ provider is not registered on the local machine while data export to MS ACCESS
- Simple post to Web Api
- What is the algorithm to convert an Excel Column Letter into its Number?
- Databindings don’t seem to refresh
- Encrypt password in App.config
- How to get JSON response from a 3.5 asmx web service
- C# Passing Function as Argument [duplicate]
- _=> what does this underscore mean in Lambda expressions?
- Proper way to move Rigidbody GameObject
- How can I write output from a unit test?
- Programmatically close aspx page from code behind
- How to iterate through a DataTable
- Accessing properties with a dot in their name
- How do I use Assert to verify that an exception has been thrown with MSTest?
- Why can’t I assign a List to a List?
- Getting current directory in .NET web application
- Type of conditional expression cannot be determined because there is no implicit conversion between ‘string’ and ‘System.DBNull’
- If my struct implements IDisposable will it be boxed when used in a using statement?
- How can I add my attributes to Code-Generated Linq2Sql classes properties?
- How to use Resources.resx to link images
- Best practices for Subversion and Visual Studio projects
- Sending Email through Outlook 2010 via C#
- Monitor child processes of a process
- Writing a Header using CsvHelper? C#