Opc.Ua.SafeLock.Enter C# (CSharp) Method

Enter() public method

Acquires the lock.
Thrown if the lock state is inconsistent.
public Enter ( ) : void
return void
        public void Enter()
        {
            System.Threading.Monitor.Enter(this);

            if (m_refs == 0)
            {
                int result = Interlocked.CompareExchange(ref m_owner, Thread.CurrentThread.ManagedThreadId, -1);

                if (result != -1)
                {
                    throw new InvalidOperationException("Operation failed because Lock object is in an invalid state.");
                }
            }

            m_refs++;
        }

Usage Example

コード例 #1
0
ファイル: Lock.cs プロジェクト: neobox3000/UA-.NET
 /// <summary>
 /// Acquires the lock on the SafeLock object.
 /// </summary>
 public Lock(SafeLock safeLock)
 {
     m_safeLock = safeLock;
     m_safeLock.Enter();
 }
All Usage Examples Of Opc.Ua.SafeLock::Enter