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 6994483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:53:54+00:00 2026-05-27T19:53:54+00:00

My process is as follows: User logs into web app and this drops an

  • 0

My process is as follows:

  1. User logs into web app and this drops an entry into the UserQueue table
  2. A Windows Service polls this table every x seconds and processes each item
  3. Once processed the item is deleted from the UserQueue table

This all works well with sequential processing but I’m concerned that a long-running task could block the queue for all other users (and this would be an issue for the web app).

I considered the BlockingCollection in .NET to hold the items in memory and then process them but I cannot guarantee that a row from the UserQueue table won’t get put into that collection more than once (due to the non-unique nature of BlockingCollection) unless I use a database flag (BeingProcessed = true for example). I’m not keen on a database flag because if my service was stopped for any reason it could leave unprocessed items in the table with the BeingProcessed = true.

Is there a more standard approach to this that I am missing or should I consider Quartz.net or similar?

  • 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-05-27T19:53:55+00:00Added an answer on May 27, 2026 at 7:53 pm

    The basic trick is to use a test-and-set with a date, rather than just a simple boolean. Here’s how you do that.

    Let’s say that your UserQueue table is super simple. Something like this, at the moment:

    create table UserQueue (id integer primary key, description varchar not null)
    

    So far, so good. But we want to safely grab a task and do something with it.

    To start, let’s alter the schema slightly:

    create table UserQueue (id integer primary key, description varchar not null,
                            dtLocked datetime null)
    

    Now, we simply follow a straight-forward procedure:

    1. Look for a job that we can claim via select * from UserQueue limit 1
    2. Attempt to lock it, setting the timestamp to NOW() where it is currently null via e.g. update UserQueue set dtLocked = NOW() where id = @id and dtLocked is null
    3. Only proceed if at least one row was updated.

    Because we’re now using a datetime for the lock, we can clean out dead tasks on a regular basis via simple update statement that deletes locks older than some amount of time—say, five minutes.

    As a bonus, this design lets you safely process multiple tasks at once, so you can eliminate any chance of a user task blocking by simply firing up more threads.

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

Sidebar

Related Questions

My app is architected as follows: I have a web service (running on GAE,
I have a process as follows: User does a complex search that is done
The web-app I'm currently building follows MVC. I've structured the servlets in a way
The code for the service is as follows System.Diagnostics.Process proc = new System.Diagnostics.Process(); //
I have a web service running on 3 servers. The woreking is as follows
I launch a child process in Java as follows: final String[] cmd = {<childProcessName>};
All instructions to disable Visual Studio hosting process I've found says as follows: Open
User scenario is like follows. My application has list of companies. Each company has
This is tricky to explain. We have a DataTable that contains a user configurable
I'm in the process of trying to setup database user authentication with Spring 3.

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.