pitersmx
pitersmx

Reputation: 957

Simultaneous data access from different threads

Hi I am developing a WinForms app which is using LocalDb with EF for data access. So far the db access in my WinForms app was performed only once at a time, just by calling:

using (var context = new EfDbContext())
{
     // do something on context entities
}

when needed.

Now I am facing a new requirement - I need to create an extra background service which will be used to periodically get the data from files located on some FTP servers, and then - update / insert the new data within this SQL LocalDb.

What I would like to achieve is to grant simultaneous access to the SQL LocalDb data for both WinForms app and this new background app (service), so that it would be possible for the user to view data from Db (in WinForm app), while an update of the data is performed in the background (by the service).

I would like to ommit the resources blocking for each other.

Can that be done (and how to do that)? Thanks!

UPDATE: I forgot to mention that the data sets which will be read from ftp files and then inserted into database may be quite large ~20-50k of records, each record consist of decimal field, DateTimeOffset field, and few Int32 fields.

Upvotes: 0

Views: 269

Answers (1)

Oleg M
Oleg M

Reputation: 265

Just use it and don't worry for now about concurrency. SQL Server widely used in highly concurrent applications like ASP.NET Web Apps and your example isn't so special. Blocking can be a problem when using transactions with write operations. But there are many Transaction isolation levels to solve this problem and it's irrelevant for now for your task I think

Upvotes: 1

Related Questions