Solved

Thread Problem: "Not enough quota is available to process this command"

Posted on 2003-11-19
12
7,023 Views
Last Modified: 2012-06-27
Hello I have a application that spaws 2 threads every five seconds.

After a day of doing this,  I start getting this message: "Not enough quota is available to process this command"

In the C++ area I did find some answer on this subject but i'm not sure how to applied it in Delphi?


Mike Colonna
 
0
Comment
Question by:colonna_mike
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
12 Comments
 
LVL 8

Expert Comment

by:gmayo
ID: 9785810
I make that over 34000 threads in one day... what on earth are you doing?!?! Do the threads die after a while?

Geoff M.
0
 
LVL 2

Expert Comment

by:Robn
ID: 9789065
"spaws 2 threads every five seconds" - what is this application doing and what is the cap on the number of threads your application creates?
Your application is eventually going to spend most of its time in context switching and die (as you have noticed).
Some people seem to believe that the more threads the application has running, the faster or more efficent it must run. This is not the case at all.

Regards,
Rob
0
 

Author Comment

by:colonna_mike
ID: 9791582
Hi,
please let me explain:
As I stated earlier the application spawns 2 threads one thread checks some directories to see if any files have arrive, if so the files names and some other information is added to a Database.  The thread then ends until the next interval.

Next, the other thread will fires off and checks to see if any files have been added.
If so it does some stuff and once the database table is empty this thread will end until the next intervals

Below is the Main thread code:

procedure TForm2.OnTerminateInsert(Sender: TObject);
begin
if not Assign(Run.FatalException) then log('error in the Insert thread!!');
IsScanning := False;
 end;


procedure TForm2.OnTerminateRun(Sender: TObject);
begin
if not Assign(Run.FatalException) then log('error in the run thread!!');
ClearLabels;
isRunning := False;
bhaveFile := False;
end;

Thread 1:
procedure TForm2.InsertTimerTimer(Sender: TObject);
begin

  if not isScanning  then
  begin
       isScanning := True;
          if not Assigned(Insert) then Insert := TInsert.Create(True)
            else
             begin
               // Insert.Free;
                Insert := nil;
                Insert := TInsert.Create(True);
             end;

        Insert.FreeOnTerminate := True;
        Insert.OnTerminate :=HandleTerminateInsert;
        Insert.Resume;
 end;
end;

Thread 2:
procedure TForm2.Timer1Timer(Sender: TObject);
begin
  if not isRunning  then
  begin
            isRunning := True;
          if not Assigned(Run) then Run := TRun.Create(True)
            else
             begin
               // Run.Free;
                Run := nil;
                Run := TRun.Create(True);
             end;
        Run.FreeOnTerminate := True;
        Run.OnTerminate :=HandleTerminateRun;
        Run.Resume;
 end;
 end;


I hope this clears things up...

Mike
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:colonna_mike
ID: 9791661
Sorry,  The two OnTerminate method are not right

procedure TForm2.OnTerminateInsert(Sender: TObject);
begin
IsScanning := False;
 end;


procedure TForm2.OnTerminateRun(Sender: TObject);
begin
ClearLabels;
isRunning := False;
bhaveFile := False;
end;

0
 
LVL 8

Expert Comment

by:gmayo
ID: 9795863
From the code you've posted, your threads don't appear to be ending. Run your program and look in Task Manager. Click on the Processes page. Select View -> Select Columns. Select thread count and sit back to watch your program. Do the threads stay fairly constant or is it going up every second?

Geoff M.
0
 

Author Comment

by:colonna_mike
ID: 9795987
Hi gmayo

Yes threads do appear to ending?
Mike C.
0
 
LVL 2

Expert Comment

by:Robn
ID: 9796709
I cannot determine if the threads are terminating or not by the code you have posted. Can you post the code in the execute method please?

Regards,
Rob
0
 
LVL 8

Accepted Solution

by:
gmayo earned 50 total points
ID: 9805564
Maybe there is some limitation on number of completed threads per day? That wouldn't surprise me, Windows having an artifical limit. However, that doesn't help you so all I can suggest is re-writing the thread so it doesn't end and simply waits a second for the next check.

For example:
procedure TMyThread.Execute;
begin
  ...do setup code...
   while not Terminated do begin
      ...do check code
      Sleep(1000);
   end;
   ....do cleanup code...
end;

Geoff M.
0
 

Author Comment

by:colonna_mike
ID: 9806413
You know that just might work, I've beating myself up trying to figure out a way around this..

I'll give this try and let you know how I make out...


MIke C.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month3 days, 19 hours left to enroll

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question