colonna_mike
asked on
Thread Problem: "Not enough quota is available to process this command"
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
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
"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
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
ASKER
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(S ender: TObject);
begin
if not Assign(Run.FatalException) then log('error in the Insert thread!!');
IsScanning := False;
end;
procedure TForm2.OnTerminateRun(Send er: 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(Se nder: 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
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(S
begin
if not Assign(Run.FatalException)
IsScanning := False;
end;
procedure TForm2.OnTerminateRun(Send
begin
if not Assign(Run.FatalException)
ClearLabels;
isRunning := False;
bhaveFile := False;
end;
Thread 1:
procedure TForm2.InsertTimerTimer(Se
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:
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
ASKER
Sorry, The two OnTerminate method are not right
procedure TForm2.OnTerminateInsert(S ender: TObject);
begin
IsScanning := False;
end;
procedure TForm2.OnTerminateRun(Send er: TObject);
begin
ClearLabels;
isRunning := False;
bhaveFile := False;
end;
procedure TForm2.OnTerminateInsert(S
begin
IsScanning := False;
end;
procedure TForm2.OnTerminateRun(Send
begin
ClearLabels;
isRunning := False;
bhaveFile := False;
end;
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.
Geoff M.
ASKER
Hi gmayo
Yes threads do appear to ending?
Mike C.
Yes threads do appear to ending?
Mike C.
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
Regards,
Rob
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
I'll give this try and let you know how I make out...
MIke C.
Geoff M.