public static void Lock(ISyncObject subject, Action action) { subject.Lock(); try { action(); } finally { subject.Unlock(); } } }