I have a thread that does a WMI query for me and I need to access some variables in the thread after it has executed the query.
The thread is created as follows ...
procedure TFormMain.RunThread;
var
WMIQ: TThreadWmiQuery;
begin
WMIQ := TThreadWmiQuery.Create(True);
...
WMIQ.OnTerminate := WMIQThreadOnTerminate;
WMIQ.Resume;
end;
and in the OnTerminate event I get the values I need like so ...
procedure TFormMain.WMIQThreadOnTerminate(Sender: TObject);
begin
Opcd := TThreadWmiQuery(Sender).P4COpcd;
Role := TThreadWmiQuery(Sender).P4CRole;
Usnm := TThreadWmiQuery(Sender).P4CUsnm;
end;
I've been told that this may not the best way to access the thread variables. Is there any other, better, ways I can easily get data from my thread without too much complexity?
Regards, Pieter