4

我在虚拟机的 Windows Vista Ultimate 上的 IIS7 上有一个示例 ISAPI 模块主机。根据IIS 7.0 版本和 Windows,Windows Vista Ultimate 的同时请求执行限制为 10。我编写了一个示例应用程序来测试 IIS7 并发请求执行限制:

procedure TForm1.Button1Click(Sender: TObject);
const c_Max = 20;
var P: TProc<string>;
    o: TThread;
    i: integer;
    A: array of TThread;
begin
  P :=
    procedure(aValue: string)
    begin
      Memo1.Lines.Add(aValue);
    end;

  SetLength(A, c_Max);
  for i := Low(A) to High(A) do begin
    o := TMyThread.Create(P, edHostName.Text, Format('test%d', [i + 1]), True);
    o.FreeOnTerminate := True;
    A[i] := o;
  end;

  for o in A do
    o.Start;
end;

constructor TMyThread.Create(const aMethod: TProc<string>; const aHostName,
    aValue: string; const aCreateSuspended: boolean);
begin
  inherited Create(aCreateSuspended);
  FMethod := aMethod;
  FHostName := aHostName;
  FValue := aValue;
end;

procedure TMyThread.Execute;
var C: TSQLConnection;
    o: TServerMethods1Client;
    S: string;
begin
  C := TSQLConnection.Create(nil);
  C.DriverName := 'DataSnap';
  C.LoginPrompt := False;
  with C.Params do begin
    Clear;
    Values[TDBXPropertyNames.DriverUnit] := 'Data.DBXDataSnap';
    Values[TDBXPropertyNames.HostName] := FHostName;
    Values[TDBXPropertyNames.Port] := IntToStr(80);
    Values[TDBXPropertyNames.CommunicationProtocol] := 'http';
    Values[TDBXPropertyNames.URLPath] := 'MyISAPI/MyISAPI.dll';
  end;

  S := Format('%d=', [ThreadID]);
  try
    try
      C.Open;
      o := TServerMethods1Client.Create(C.DBXConnection);
      try
        S := S.Format('%s%s', [S, o.EchoString(FValue)]);
      finally
        o.Free;
      end;
    except
      on E: Exception do
        S := S.Format('%s%s', [S, E.Message]);
    end;
  finally
    Synchronize(
      procedure
      begin
        FMethod(S);
      end
    );
    C.Free;
  end;
end;

当我单击 Button1 时,Memo1 显示 20 行字符串(ThreadID=EchoString 的结果),即使我将常量变量 c_Max 更改为 500,我仍然无法获得任何字符串行(ThreadID=Exception 消息)显示备忘录1。我的问题是如何测试 IIS7 同时请求执行限制?

4

0 回答 0