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

  • Home
  • SEARCH
  • 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 168449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:27:20+00:00 2026-05-11T12:27:20+00:00

I would like some advice from anyone experienced with implementing something like pessimistic locking

  • 0

I would like some advice from anyone experienced with implementing something like ‘pessimistic locking’ in an asp.net application. This is the behavior I’m looking for:

  1. User A opens order #313
  2. User B attempts to open order #313 but is told that User A has had the order opened exclusively for X minutes.

Since I haven’t implemented this functionality before, I have a few design questions:

  • What data should i attach to the order record? I’m considering:
    • LockOwnedBy
    • LockAcquiredTime
    • LockRefreshedTime

I would consider a record unlocked if the LockRefreshedTime < (Now – 10 min).

  • How do I guarantee that locks aren’t held for longer than necessary but don’t expire unexpectedly either?

I’m pretty comfortable with jQuery so approaches which make use of client script are welcome. This would be an internal web application so I can be rather liberal with my use of bandwidth/cycles. I’m also wondering if ‘pessimistic locking’ is an appropriate term for this concept.

  • 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. 2026-05-11T12:27:21+00:00Added an answer on May 11, 2026 at 12:27 pm

    It sounds like you are most of the way there. I don’t think you really need LockRefreshedTime though, it doesn’t really add anything. You may just as well use the LockAcquiredTime to decide when a lock has become stale.

    The other thing you will want to do is make sure you make use of transactions. You need to wrap the checking and setting of the lock within a database transaction, so that you don’t end up with two users who think they have a valid lock.

    If you have tasks that require gaining locks on more than one resource (i.e. more than one record of a given type or more than one type of record) then you need to apply the locks in the same order wherever you do the locking. Otherwise you can have a dead lock, where one bit of code has record A locked and is wanting to lock record B and another bit of code has B locked and is waiting for record A.

    As to how you ensure locks aren’t released unexpectedly. Make sure that if you have any long running process that could run longer than your lock timeout, that it refreshes its lock during its run.

    The term ‘explicit locking’ is also used to describe this time of locking.

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

Sidebar

Ask A Question

Stats

  • Questions 275k
  • Answers 275k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer ret[0] = (byte)(x & 0xff); ret[1] = (byte)((x >> 8)… May 13, 2026 at 2:31 pm
  • Editorial Team
    Editorial Team added an answer It depends: time to resolve the DNS name to IP… May 13, 2026 at 2:31 pm
  • Editorial Team
    Editorial Team added an answer There are plenty ways of implementing inheritance and behavior reuse… May 13, 2026 at 2:31 pm

Related Questions

I've been trying to do more Web development work recently (I currently do other
I'm looking for design patterns (GOF, but others would be welcome too) for Delphi
I know a lot of question regarding VB6 migration have been asked, but I
I've got a standard UITableViewCell where I'm using the text and image properties to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.