public static ThreadCounts CompareExchangeCounts(ref ThreadCounts location, ThreadCounts newCounts, ThreadCounts oldCounts) { ThreadCounts result = new ThreadCounts { _asLong = Interlocked.CompareExchange(ref location._asLong, newCounts._asLong, oldCounts._asLong) }; if (result == oldCounts) { result.Validate(); newCounts.Validate(); } return(result); }