Answer the question
In order to leave comments, you need to log in
Delphi XE5 why doesn't "suspend, resume, terminate" work in a thread?
Hello. I create a thread in delphi: postThread.Create(true);
Everything works fine, but I need to stop and suspend the execution of this thread in the program, but for this I need the "Terminate, Suspend, Resume" methods, but, for some unknown reason, they do not work. Delphi refuses to compile the code, indicating an error in the code: postThread.Terminate;
Here is the error itself:
[dcc32 Error] Unit4.pas(63): E2076 This form of method call only allowed for class methods or constructor
Answer the question
In order to leave comments, you need to log in
Your PostThread is not a variable, but a type. Therefore the code
type
PostThread = class (TThread)
end;
PostThread.Create(true);
PostThread.Create
goes nowhere. And challenges PostThread.Resume
and the like are impossible - they are not class-based. It should be something like this...type
TPostThread = class (TThread)
end;
var
PostThread : TPostThread;
…
PostThread := TPostThread.Create(true);
PostThread.Resume; // Suspend, Terminate и так далее…
…
PostThread.Free; // Ну и убить его, наконец!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question