delphi try except

来源:百度知道 编辑:UC知道 时间:2024/06/24 09:56:03
try except
抛出异常的时间太长了 怎么缩短响应时间? 比如说1秒没try成功就转到except。
或者在timer事件中 怎么时间到了转到button1的except事件中?
谁解决了http://zhidao.baidu.com/question/51918041.htmlhttp://zhidao.baidu.com/question/51993684.html里的300分一并送

//在界面上放一个Timer控件,设置Interval为1000即1秒,当然也可以根据实际情况设置为100,500,以缩短判断时间。
//然后在Timer执行时,记录流逝时间。
//最后在你要处理的过程中,加入对流逝时间的判断,如果大于你预期的时间,则抛出异常。
//---------------------------------------------------
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, ExtCtrls;

type
EMyException = class(Exception);
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
Memo1: TMemo;
Memo2: TMemo;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
UsedTime:Integer=0;//秒
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var ii:integer;
begin
UsedTime:=0;
Timer1.Enabled :=True;<