vb.netmultithreadingsql-server-cesmart-device

SQL Server CE database thread safety


I'm creating a vb.net smart device application that utilizes a SQL Server CE 3.5 database and an in-memory dataset bound to input controls as an intermediary.

I would like to maximize the performance of the UI by placing the database update routines on a separate thread, but am concerned about the possibility of the application attempting to make an update before another has finished. Is this a real possibility or is SQL Server CE able to queue the updates?

Microsoft states, "Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe." in the documentation for the SqlCeDataAdapter class, but I don't have enough experience in the matter of multithreading to interpret this properly.


Solution

  • None of the SQL Server CE objects are thread safe, so only use a single thread for the background updates. Also, consider using the TableDirect APIs for optimal INSERT and UPDATE performance on a constrained device.