MainFrm.pas
上传用户:psxgmh
上传日期:2013-04-08
资源大小:15112k
文件大小:1k
- unit MainFrm;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls;
- type
- TForm1 = class(TForm)
- Button1: TButton;
- Memo1: TMemo;
- procedure Button1Click(Sender: TObject);
- private
- SortThread: TThread; //线程实例
- aSort: array of integer; //排序数组
- procedure SortOver(sender: TObject); //当排序执行完后执行的过程
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- uses SortU;
- {$R *.dfm}
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- //排序数组赋值
- setLength(aSort, 4);
- asort[0] := 13;
- aSort[1] := 9;
- aSort[2] := 15;
- aSort[3] := 12;
- //创建SortThread实例,并执行线程
- SortThread := TSortThread.Create(False, aSort);
- SortThread.OnTerminate := SortOver; //当线程终止时,调用SortOver方法显示排序后数组
- end;
- procedure TForm1.SortOver(Sender: TObject);
- var
- i: integer;
- begin
- Memo1.Lines.Clear;
- for i := 0 to 3 do
- begin
- Memo1.Lines.Add(intToStr(aSort[i]));
- end;
- end;
- end.