Acquire _stateLock when executing Beat in the .NET client

#1763
Add a Trace lock to the .NET client

#1766