Procedure Level Locking 
Author Message
 Procedure Level Locking

Does someone know how to do a locking on a sub or function? Only for a
particular function since the function is shared by many threads. I don't want
to lock the whole class, only the function.
--
"When people are free to do as they please, they usually imitate each other."
                                                                    Eric Hoffer


Sun, 03 Apr 2005 22:46:12 GMT  
 Procedure Level Locking
Hi Eric,

If you have a member of your class that is only used in the function or sub
you want to lock then using SyncLock with that member will lock just the
method. For example:

    Public Class Example

        Public Function LockMe() As String
            SyncLock m_SyncLockObject
                'Do the work
            End SyncLock
        End Function

        Private m_SyncLockObject As Object = new Object()
    End Class

Craig
VBTeam
--
This posting is provided "AS IS" with no warranties, and confers no rights.

___


Quote:
> Does someone know how to do a locking on a sub or function? Only for a
> particular function since the function is shared by many threads. I don't
want
> to lock the whole class, only the function.
> --
> "When people are free to do as they please, they usually imitate each
other."
>       Eric Hoffer



Mon, 04 Apr 2005 05:00:41 GMT  
 Procedure Level Locking
Does the object need to be shared or not?


Quote:
>Hi Eric,
>If you have a member of your class that is only used in the function or sub
>you want to lock then using SyncLock with that member will lock just the
>method. For example:
>    Public Class Example
>        Public Function LockMe() As String
>            SyncLock m_SyncLockObject
>                'Do the work
>            End SyncLock
>        End Function
>        Private m_SyncLockObject As Object = new Object()
>    End Class
>Craig
>VBTeam
>--
>This posting is provided "AS IS" with no warranties, and confers no rights.
>___


>> Does someone know how to do a locking on a sub or function? Only for a
>> particular function since the function is shared by many threads. I don't
>want
>> to lock the whole class, only the function.
>> --
>> "When people are free to do as they please, they usually imitate each
>other."
>>       Eric Hoffer



Tue, 05 Apr 2005 11:00:57 GMT  
 Procedure Level Locking
I've tested the program, and it seems that I don't have to put shared for the
object. Correct me if I'm wrong? And also is there any other way since I'm not
using any object at all. Everything is passed through parameter and then the
function will only call a specific method inside the parameters. So I won't
need to create a new object. In this case, I don't think this method of locking
will work. Any other suggestion?


Quote:
>Does the object need to be shared or not?

>>Hi Eric,
>>If you have a member of your class that is only used in the function or sub
>>you want to lock then using SyncLock with that member will lock just the
>>method. For example:
>>    Public Class Example
>>        Public Function LockMe() As String
>>            SyncLock m_SyncLockObject
>>                'Do the work
>>            End SyncLock
>>        End Function
>>        Private m_SyncLockObject As Object = new Object()
>>    End Class
>>Craig
>>VBTeam
>>--
>>This posting is provided "AS IS" with no warranties, and confers no rights.
>>___


>>> Does someone know how to do a locking on a sub or function? Only for a
>>> particular function since the function is shared by many threads. I don't
>>want
>>> to lock the whole class, only the function.
>>> --
>>> "When people are free to do as they please, they usually imitate each
>>other."
>>>       Eric Hoffer



Tue, 05 Apr 2005 11:35:39 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Locking on procedure level

2. Row level locking use system stored procedure via ADO

3. dim at procedure level or module level

4. How to cancel a large multiple level procedure from several levels in

5. Access 97 Row-Level Record Locking

6. row-level locking with dao and access 2000

7. Record-level locking

8. Record Level Locking Possible with Access?

9. Workaround for the Lack of Record-Level Locking

10. Command Object vs Connection Object for Row Level Locking

11. Command Object vs Connection Object for Row Level Locking

12. Record-level locking?

 

 
Powered by phpBB® Forum Software