开发者

Does Sql Server CE support Multithreading?

I need to know if SQL Server CE supports Multithreading (using one connection).

So if I create a SQL Server CE connection and then use that connection in two different threads to call an update/insert/delete to the connection, will SQL Server CE be "OK" with that or will it choke sometimes?

(I am getting an intermittent write error and I am not sure if it is b开发者_如何学Cecause of multithreaded access or if it is something else.)


You must create a connection object per thread, it is not safe for multithreading - http://msdn.microsoft.com/en-us/library/system.data.sqlserverce.sqlceconnection(v=VS.100).aspx


Yep sqlserverce is not multi-thread safe.

The best way to and the laziest one is to each call for an insert, update task do an lock to an object , do the necessary operation and then release that lock.

I had an class does some insertions (entering an gps coordinate in the db) depending on an timer, on an event (pda connected to the ac powerline), and the another timer to send those data to an webservice via gprs. Final result: sql crashed, reason it is not multi-thread safe.

After some research, found this article C Threading Sharing data across threads that helped in my case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜