What is the best sample for creating datasets thread safe when writing?
The best I can find in googling is to "implement a shell layer with locks," but blushing seems pretty dirty at first.
Can someone recommend / point me towards a good solution? This is probably a problem that has already been resolved somewhere.
edit: I also need to bind the dataset to the ui grid, which complicates things a bit.
“Embed a wrapper using locks” is the way to go.
The shell layer will probably use a lock specific to how your application uses DataSets.
, DataSet, , .
, , , , , - (DataSet.Tables, DataTable.Rows,...).
, .
, Interlocked class . .
, , , . . .
Embed a shell using locks. Jokes aside. You cannot subclass important methods, since they are available, your thread safety may be compromised.
Well, you can also implement a set of methods that optimize threads and stick to them, but this will only work if you don't need to pass the DataSet to a third-party library that will access it directly.