Working with Compact Framework and SqlCe, there can be a lot of issues with performance, memory leaks and thread synchronisations.
Rules to abide by to minimise Compact Framework - SqlCe headaches.
- Use one SqlCe connection - you can use a locking mechanism on the connection to enable the use of one connection on multiple threads.
- Bulk Data inserts are slow because of the Sqlce Engine. Use direct table inserts, which has a similar performance benefit to writing directly to a text file.
- Dispose the SqlCe connection on close of the application. This makes sure all resources are cleaned up.
- Dispose all commands, datareaders etc after every call to the database. Using statements are your friend. Make sure reader objects are inside command using statements etc...