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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:22:46+00:00 2026-05-10T23:22:46+00:00

I am new to threads and in need of help. I have a data

  • 0

I am new to threads and in need of help. I have a data entry app that takes an exorbitant amount of time to insert a new record(i.e 50-75 seconds). So my solution was to send an insert statement out via a ThreadPool and allow the user to begin entering the data for the record while that insert which returns a new record ID while that insert is running. My problem is that a user can hit save before the new ID is returned from that insert.

I tried putting in a Boolean variable which get set to true via an event from that thread when it is safe to save. I then put in

while (safeToSave == false)   {       Thread.Sleep(200)   }   

I think that is a bad idea. If i run the save method before that tread returns, it gets stuck.

So my questions are:

  1. Is there a better way of doing this?
  2. What am I doing wrong here?

Thanks for any help.
Doug

Edit for more information:

It is doing an insert into a very large (approaching max size) FoxPro database. The file has about 200 fields and almost as many indexes on it.
And before you ask, no I cannot change the structure of it as it was here before I was and there is a ton of legacy code hitting it. The first problem is, in order to get a new ID I must first find the max(id) in the table then increment and checksum it. That takes about 45 seconds. Then the first insert is simply and insert of that new id and an enterdate field. This table is not/ cannot be put into a DBC so that rules out auto-generating ids and the like.

@joshua.ewer
You have the proccess correct and I think for the short term I will just disable the save button, but I will be looking into your idea of passing it into a queue. Do you have any references to MSMQ that I should take a look at?

  • 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-10T23:22:47+00:00Added an answer on May 10, 2026 at 11:22 pm

    Everyone else, including you, addressed the core problems (insert time, why you’re doing an insert, then update), so I’ll stick with just the technical concerns with your proposed solution. So, if I get the flow right:

    • Thread 1: Start data entry for record

    • Thread 2: Background calls to DB to retrieve new Id

    • The save button is always enabled, if user tries to save before Thread 2 completes, you put #1 to sleep for 200 ms?

    The simplest, not best, answer is to just have the button disabled, and have that thread make a callback to a delegate that enables the button. They can’t start the update operation until you’re sure things are set up appropriately.

    Though, I think a much better solution (though it might be overblown if you’re just building a Q&D front end to FoxPro), would be to throw those save operations into a queue. The user can key as quickly as possible, then the requests are put into something like MSMQ and they can complete in their own time asynchronously.

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

Sidebar

Ask A Question

Stats

  • Questions 65k
  • Answers 65k
  • 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
  • added an answer Look at the simple framework from CloudMade: http://developers.cloudmade.com/projects/show/iphone-api I use… May 11, 2026 at 11:20 am
  • added an answer What about age[^0-9]{0,4}[0-9]+ if you want to capture the number… May 11, 2026 at 11:20 am
  • added an answer One way is to assign a unique number to each… May 11, 2026 at 11:20 am

Related Questions

I am new to threads and in need of help. I have a data
I am new to C# and am doing some work in an existing application.
I am new to developing for Office Forms Server / MOSS 2007. I have
I am new to all the anonymous features and need some help. I have
I am new to any scripting language. But, still I worked on scripting a
I am new to any scripting language. But, Still I worked on scripting a
I am new to visual studio/asp.net so please bear with me. Using vs 2005
I am new to asp and have a deadline in the next few days.
I am new to the world of ASP.NET and SQL server, so please pardon
I am new to python and struggling to find how to control the amount

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.