Threads and Row level read lock using LINQ RRS feed

  • Question

  • HI ,

    I am reading the data in a thread which is running after specified interval.
    I want to run parallel thread but i dont want the record read by a thread , should not br read by the thread running.(There is some interval in thread start but they proceess may continue )

    I want to implement this locakin mecanisum using LINQ...
    Is there any way to preavent the other thread to read the data locked by the other.

    Thanks and Regards
    Wednesday, July 23, 2008 1:39 PM


  • Hi Nakul,

    As far as I know, to make a Thread Safety program in multi-threads environment, we can use the lock Statement, all the code which wrapped in lock statement is ensured that only one thread can execute it in one time, in my opinion, we can wrap the LINQ code snippet with lock statement in this scenario.

    As an alternative for lock statement, we can also use the Mutex Class to make sure the shared data is Thread-Safety.

    For LINQ to SQL, to do some actions which would modify the data of a database, generally speaking, the associated DBMS (database management system) would make sure the data in database is Thread-safety.

    But as far as I aware,  I do not think LINQ has any lock mechanism, just like SQL, no lock mechanism as well.



    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by jack 321 Monday, July 28, 2008 11:24 AM
    Friday, July 25, 2008 9:04 AM