Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8050835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:10:02+00:00 2026-06-05T07:10:02+00:00

I have a website I’ve built in VS2010 which is using MVC3 (Razor) I

  • 0

I have a website I’ve built in VS2010 which is using MVC3 (Razor)

I use DBContexts to access the datbase, my connection string is:

<add name="SystemDBContext"
connectionString="Data Source=|DataDirectory|System.sdf"
providerName="System.Data.SqlServerCe.4.0" />

I want to have a game loop so I’ve started a new thread in Application_Start which loops and accesses the database using the DBContext.

What seems to be happening is that the loop uses the DBContext and locks the db file, and then whenever you try to make changes from the DBContext on the website itself, the file is in use.

It’s not when I declare DBContext, it happens whenever I try to use the DBContext to perform a search or update of some sort.

Here’s my Global.asax

    protected void Application_Start()
    {
        ...
        Manager m = new Manager();
        Thread t = new Thread(m.Start);
        t.Start();
    }

Part of one of my controllers:

public class myController : Controller
{
    private SystemDBContext db = new SystemDBContext();


    public ViewResult Index()
    {
        var engines = db.Engines.Include(e => e.state);
        return View(engines.ToList());
    }
    ...

And my loop looks something like this:

public class Manager
{
    public void Start()
    {
        while (true)
        {
            SystemDBContext db = new SystemDBContext();
            var query = from ...
        }
        ...

What is the best practice for doing this? I’ve been thinking of Singletons, Locks or Synclocks, adjusting the connection string to allow multiple attaches to the database file, or having my loop request a web page that does the update.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:10:03+00:00Added an answer on June 5, 2026 at 7:10 am

    What seems to be happening is that the loop uses the DBContext and locks the db file, and then
    whenever you try to make changes from the DBContext on the website itself, the file is in use.

    Back to reading the documentation? The part where it says WinCE is NOT A SERVER FOR MULTIPLE THREADS. Use SQL Server instead – Express is free. CE is for limited scalability items, single threaded access.

    What is the best practice for doing this?

    Use a proper database server. CE is HEAVILY problematic, especially if you start / stop the database engine all the time, which results into a LOT of inefficient disc access.

    SQL Server is done for exactly that and as I said – Express is cheap.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using win7. and i have website which i want to test it with
I have a website which is using .net 3.5, IIS7 and SQL Server 2008.
I have website on the server, which is not precompiled (with source code, so
I have website where users can login with their Facebook account. I am using
i have website of application which sells applications online.on the home page i want
I have website built by html5 and served by Apache, I have installed Nodejs
So, if I have website project Foo which has a reference to class library
I have a website ( http://www.rtistree.com ) which has vertical scrollbar on some pages.
I have website which works fine and have following in the htaccess file RewriteEngine
I have website that use XMLHttpRequest (jQuery, actually). I also have another site running

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.