Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to Control Concurency using Threads in vb.net

vuyiswamvuyiswam Posts: 1Member
Good afternoon All

i have an Application in an Multiuser evironment, i have a Concurency Problem. i would like someone to Explain to me how to handle Concurency using thread, i would like to lock the Update Function when one of users is updating the records and unlock it when the process is done . here is an example of my code

[code]
Public Function SaveProperties_Lis(ByVal dsDAta As PropDAL.Dssearchlis) As PropDAL.Dssearchlis

Dim ws As PropDAL.Properties

Try
ws = New PropDAL.Properties

'check the Business Rules
Me.CheckRules_Lis(dsDAta)

'Updating the dataset
dsDAta.EndInit()

ws.UpdateLis_search(dsDAta)

Catch ex As Exception
MsgBox(ex.Message)
End Try

Return dsDAta

End Function[/code]
i have this Function in BLL(Business Logic Layer). i want to lock it , when another user is using it.
The Bll is running on the Client machine and its a DLL that is deployed with the Application. i need to trap the Concurency situation in the BLL. The code above is retreaving the data from the DAL(data Access Layer), so the BLL will create an object of a DAL and use the DAL functions, and the Client application will call the BLL for service by creating an object of BLL and use the methods of BLL that will use the methods of DAL, i have not prevented Concurency to a database,and thats what i want to do. i want to know how to achieve this in a multi user Environment.

Thanks

Comments

  • rlcrlc Posts: 448Member
    In a central place like a global Module...
    [code]
    Dim g_ThreadLock as new system.threading.mutex
    [/code]

    Where ever you want to lock...
    [code]
    Try

    g_threadlock.waitone()

    'do cool stuff here

    finally

    g_threadlock.releasemutex()

    end try
    [/code]

    ~rlc

Sign In or Register to comment.