特别在internet上,让用户等候处理结果是非常不明智的。用 Remobject的异步调用易如反掌。
在D2007中IDE调用SERVICE BUILDER菜单codegen/delphi/async interface生成单元_Async.pas。在自己的单元中如:myunit.pas 使用uses _Async.pas。
接下来在myunit.pas中增加2各按钮:invoke_buttom 和receive_buttom,再增加一个timer。
procdure invoke_buttom (...)
begin
fProxy := CoCalcServer_Async.Create(binmessage1,htpchannel1);
fProxy.Invoke_???(...);
invoke_buttom.Enabled := False;
end;
procdure receive_buttom (...)
begin
ShowMessage(ReceiveClick(...);
fProxy. := nil;
invoke_buttom.Enabled := True;
receive_buttom.Enabled := False;
end;
procdure time1_checktimer(...)
begin
receive_buttom.Enabled := Assigned(fProxy) and
fProxy.AnswerReceived;
end;
fProxy.AnswerReceived属性在接口中已经定义。用于判断调用是否完成。
本文介绍如何在Delphi中使用Remobjects组件实现服务的异步调用。通过简单的步骤创建异步接口并集成到项目中,实现按钮触发的服务调用及结果接收。
3783

被折叠的 条评论
为什么被折叠?



