Recent

Author Topic: Independent Thread and Program/Független Programszál és Program (Multilang)  (Read 5614 times)

TheProgrammer

  • New Member
  • *
  • Posts: 48
  • Translator and programmer/Fordító és programozó
    • SourceCodePower.com
I need some help to use a Thread...
Kellene kis segítség a Thread használatához...

http://www.lazarus.freepascal.org/index.php/topic,14291.msg75831/topicseen.html#new

If the thread is busy then the program is too busy.
Ha túlterhelt a thread akkor a program is túlterhelt.

The thread use WMI ole object and this do freeze two second, because the ole object connecting to server... Then program is too freeze on two second. (2 connect = 4 second freeze)
A programszál WMI ole objektumot használ és lefagyasztja két másodpercre, mert csatlakozik a szerverhez. Ekkor a program befagy 2 másodpercre... (2 kapcsolódás = 4 másodperc lefagyás)

The program and the thread would not run on separate?
A programnak és a threadnak nem kellene külön futniuk?

Example/Példa:
Thread working but the program can be used independently. Or no?
Thread dolgozik, de a programot attól független lehet használni. Vagy nem?
Code: [Select]
procedure TForm1.Buttom1Click(Sender: TObject);
begin

MyThread := TMyThread.Create(True);
MyThread.FreeOnTerminate := False;
MyThread.Priority := tpNormal;
MyThread.OnTerminate := @EndFunction;
MyThread.Resume;

end;

Thread unit:
Code: [Select]
unit MyThreadSource;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, MyOleWMISource;

type

    TMyThread = class(TThread)
       Info1 : String;
       [..]
       MyOleWMI : TMyOleWMI;
       procedure OpenMyOleWMI;
    protected
       procedure Execute; override;
    end;


implementation


procedure TMyThread.OpenMyOleWMI;
begin
OpenMyOleWMI := TOpenMyOleWMI.Create;
OpenMyOleWMI.SystemInfoCreate; //Class in class// = OpenMyOleWMI.System.Create;

Info1 := OpenMyOleWMI.System.InfoA;
[..]

OpenMyOleWMI.SystemInfoDestroy;
OpenMyOleWMI.Destroy;
end;



procedure TMyThread.Execute;
begin
Synchronize(@OpenMyOleWMI);
end;

end.


Code: [Select]
procedure TForm1.EndFunction(Sender: TObject);
begin
Label1.Caption := MyThread.Info1;
MyThread.Free;
end;
« Last Edit: August 22, 2011, 06:54:22 pm by TheProgrammer »
Translator and programmer/Fordító és programozó (Multilang)
My webpage/Weboldalam:
www.sourcecodepower.com

jixian.yang

  • Full Member
  • ***
  • Posts: 173
On windows the registration table is much better than WMI objects for computer information.

At least it is faster and stable than WMI objects. Most of the hardware information stored in the registration table.

 

TheProgrammer

  • New Member
  • *
  • Posts: 48
  • Translator and programmer/Fordító és programozó
    • SourceCodePower.com
Right! But there is no core, clock speed or cache ...
I need the fiber to the program freezes the program will still work ...

Igaz! De ott nincs mag, órajel vagy gyórsítótár...
Nekem az kell hogy ha a programszál befagy akkor a program még működjön...

Previous topic/Előző téma:
Windows Hardware information/Windows hardver információ
http://lazarus.freepascal.org/index.php/topic,14291.0.html
Translator and programmer/Fordító és programozó (Multilang)
My webpage/Weboldalam:
www.sourcecodepower.com

 

TinyPortal © 2005-2018