View Issue Details

IDProjectCategoryView StatusLast Update
0003314JEDI VCL00 JVCL Componentspublic2005-11-18 04:03
ReportermarcgeldonAssigned Tojfudickar 
PrioritynormalSeverityblockReproducibilityalways
Status resolvedResolutionunable to reproduce 
Product Version3.00 
Target VersionFixed in Version 
Summary0003314: JvThread not working if created in procedure
DescriptionTJvThread do not work, if you create the component manually. Check the additional information. You can find a demo there.

Additional Informationprocedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
  FThread: TJvThread;
begin
  try
    // create thread
    FThread := TJvThread.Create(Self);
    FThread.Exclusive := False;
    FThread.RunOnCreate := False;
    FThread.FreeOnTerminate := True;
    FThread.OnExecute := FThreadExecute;

    for i := 1 to 3 do
    begin
      FThread.Execute(Self);
    end;

    for i := 0 to FThread.Count-1 do
    begin
      FThread.Threads[i].resume;
    end;

    while not FThread.Count = 0 do
    begin
      Sleep(100);
    end;
  finally
    FreeAndNil(FThread);
  end;
end;

procedure TForm1.FThreadExecute(Sender: TObject; Params: Pointer);
var
  i: Integer;
  j: Integer;
begin
  // just do something
  for i := 0 to 10000 do
  begin
    j := i;
  end;
end;
TagsNo tags attached.

Activities

marcgeldon

2005-11-16 02:20

reporter   ~0008089

the threads don't terminate. If I do the same thing in a Form (I create the non-visible object TJvThread in a form, set the properties and so on) it does work without any problem.

Why do I want to create TJvThread manually? I have a component where it should working on. But it doesn't. Same problem as in this example.

marcgeldon

2005-11-16 05:36

reporter   ~0008091

Ok I found the problem. If I put a "Application.ProcessMessages;" in the while loop (while not (FThread.Count = 0) do), it does work.

Also the correct while loop is =
while not (FThread.Count = 0) do

I think we can close this bug

Issue History

Date Modified Username Field Change
2005-11-16 02:12 marcgeldon New Issue
2005-11-16 02:20 marcgeldon Note Added: 0008089
2005-11-16 05:36 marcgeldon Note Added: 0008091
2005-11-18 04:03 jfudickar Status new => resolved
2005-11-18 04:03 jfudickar Resolution open => unable to reproduce
2005-11-18 04:03 jfudickar Assigned To => jfudickar