MASTERING DELPHI 6 phần 9

Bạn nên tránh làm điều này làm việc trên các ứng dụng client, thay vào đó, viết các quy tắc kinh doanh của bạn trên tầng giữa. Trong kiến trúc DataSnap, bạn có thể gửi một số hạn chế từ máy chủ cho khách hàng và để cho chương trình khách hàng áp đặt những hạn chế trong quá trình người dùng nhập vào. | 864 Chapter 20 From Automation to COM or to use the very precise timing functions of the multimedia support unit MMSystem. Here is the code of one of the methods they are quite similar procedure Sender TObject var I K Integer Ticks Cardinal begin crHourglass try Ticks GetTickCount K 0 for I 1 to 100 do K K Ticks GetTickCount - Ticks Format Interface d - Seconds .3f K Ticks 1000 finally crDefault end end With this program you can compare the output obtained by calling this method based on an interface the corresponding version based on a variant and even a third version based on a dispatch interface. An example of the output which is added to a list box so you can do several tests and compare the results is shown in Figure . Obviously the timing depends on the speed of your computer and you can also alter the results by increasing or decreasing the maximum value of the loop counter. FIGURE The TLibCli OLE Automation controller can access the server in different ways with different performance results. Notice the server window in the background. Copyright 2001 SYBEX Inc. Alameda CA Writing an OLE Automation Server 865 We ve already seen how you can use the interface and the variant. What about the dispatch interface You can declare a variable of the dispatch interface type in this case var DMyServer IFirstServerDisp Then you can use it to call the methods as usual after you ve assigned an object to it by casting the object returned by the CoClass DMyServer as IFirstServerDisp Looking at the timing and at the internal code of the example there is apparently very little difference between the use of the interface and of the dispatch interface because the two are actually connected. In other words we can say that dispatch interfaces are a technique in between variants and interfaces but they deliver almost all of the speed of interfaces.

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.