I have a case where i have to implement an addition atomically and just to save a statement - i did the below
int result = Interlocked.Add(ref int source, await ComputeAsync(object someObj);
public async Task<int> ComputeAsync(object someObj)
{
// some operations
....
}
Is there anything wrong with the above Interlocked.Add statement. Can we pass an await function which returns an int as param to the add stmt? What are the implications if any ?