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.
Regards,
Xun
Please remember to mark the replies as answers if they help and unmark them if they provide no help.