Results 1 to 3 of 3

Thread: [RESOLVED] Lock from C# .Net to VB .Net

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2006
    Location
    Moscato , Athens , Greece
    Posts
    60

    Resolved [RESOLVED] Lock from C# .Net to VB .Net

    Hello ,

    can any one help me convert that property to vb .net

    Code:
    public override int Capacity 
    {
    	get 
    	{ 
    		lock (_root);
    		return _collection.Capacity; 
    	}
    	set
    	{
    		lock (_root);
    		_collection.Capacity = value;
    	}
    }
    the proble is , i don't know how i change the lock

    VB Code:
    1. Public Overrides Property Capacity As Integer
    2.     Get
    3.             [COLOR=DarkRed]'lock (_root);[/COLOR]
    4.             Return _collection.Capacity
    5.         End Get
    6.         Set
    7.             [COLOR=DarkRed]'lock (_root);[/COLOR]
    8.             _collection.Capacity = value
    9.         End Set
    10. End Property

    thanks in advance
    geobest

  2. #2
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    710

    Re: Lock from C# .Net to VB .Net

    SyncLock is the VB equivalent to C#'s "lock".
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com

  3. #3
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    710

    Re: Lock from C# .Net to VB .Net

    By the way, if that C# code was an actual property, then the "lock" is serving no purpose since the lock block has no code.

    Usually you would do something like this in C#:
    lock (foo)
    {
    //code regarding 'foo'
    }

    In your case you have just "lock (_root);", i.e., the empty statement ";" is the only target of the lock. Your code just locks "_root" and then releases the lock.
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width