add atomic lock in ref class