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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:47:44+00:00 2026-05-19T01:47:44+00:00

I’ve got a multithreaded app using the OmniThreadLibrary . I am misusing the OTL

  • 0

I’ve got a multithreaded app using the OmniThreadLibrary. I am misusing the OTL to open ADO stored procedures in secondary threads which works unless there’s an error (and mostly even then). Unfortunately in this particular case there’s a problem.

When I open a particular form I get an exception in a thread “There must be at least one field” copying a dataset into a kb memory table, which I handle and send a message to a monitoring thread. That message arrives and is stored successfully in the database. When I close that form the main VCL thread hangs.

kbMemTable.LoadFromDataset(StoredProc, []); // throws

Pausing the app in the debugger and looking at the thread list the main VCL thread shows:

"Blocked on critical section which is abandoned owned by Process 0"

The OTL threads are still live and time out of the thread pool, so it seems that everything is working except the main thread. I’m also using DevExpress and Raise components which have their own threads but don’t name them (and don’t seem to be part of the problem) which means I have 12 threads of which only 5 are identifiable.

I strongly suspect that something in the Delphi database has grabbed that critical section then failed to release it due to the exception. There don’t seem to be any critical sections in the Delphi/database source code units that I’m using directly, but obviously there’s one there somewhere.

This involves way too much source code to include, and my test app doesn’t display the behaviour.

I’m asking for any tips on tracking this down.

My current thought is to switch to debug dcu’s and breakpoint every critical section creation I can find, then see what happens. I could address the problem that’s throwing the first exception, but I’m concerned that some other exception could have the same effect out in the field where it would be a pain to deal with. So I’d like to fix this problem first.

Edit: the critical section is owned by the thread that calls TADOStroredProc.ExecProc. That thread completes normally after handling the exception, so unless I leap into the debugger quickly the thread ages out of the pool before I see it, hence the ProcessID=0 above. Setting the thread linger time to 60s instead of 10s at least gives me that.

  • 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-19T01:47:44+00:00Added an answer on May 19, 2026 at 1:47 am

    First, I don’t see why you’re calling opening an ADO stored proc in a background thread a “misuse” – it should work flawlessly, unless you have some mess in the different threads’ apartments or other messaging (eg the monitoring thread notifications).

    I don’t know what exactly causes your problem, but I will share some experiences on the Delphi ADO multithreading field. The COM/OLE STA messaging is the main suspect here.

    Background threads should really better be as MTA. I don’t know if Delphi 2010 does this by itself, but Delphi 2006 doesn’t – to make sure, look in the sources for calls to CoInitializeEx – if not called w/ the COINIT_MULTITHREADED=$00 flag, the thread is considered apartment-neutral and marshals through the STA/main thread. Every other init method will get you a nice STA thread.

    You should:

    • provide your backround threads with proper COM ini-/finalization as MTA
    • use all ADO components only from the apartment which created them
    • not create other STA threads (main thread is one by default); combining the messaging w/ other locking is jist too much of a PITA
    • never use the ADO async abilities together with multithreading
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
i got an object with contents of html markup in it, for example: string
I've got a string that has curly quotes in it. I'd like to replace
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a JSP page retrieving data and when single or double quotes are

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.