TAILIEUCHUNG - C# 3.0 Cookbook phần 5

ngoại trừ phương pháp định nghĩa là luôn luôn hiện diện trong các phương pháp có điều kiện, ngay cả khi điều kiện không được đáp ứng. Phương pháp một phần không giữ lại định nghĩa phương pháp nếu có là không thực hiện phù trường hợp này, bạn đang tìm kiếm cho hệ thống phân cấp loại | In the TestIndividuallnvokesExceptions method of this recipe if an exception is caught it is logged to the event log and displayed tpen tpe Cdpe continues to invoke delegates. This strategy allows for as fine-grained handling of exceptions as you need. One way to deal with this st to dore all of the exceptions ttn encur during delegate irocessinge and then wrai all of the exceitions encountered during irocessing in a custom exception. After processing completes throw the custom exception. See the MulticastInvocationException class in the Solution. By adding a finally block to this try-catch block you could be assured that code within this finally block is exccuted aterr every deregare returns. Thie esehnipue is useful if you want to interleaie code between calls to delegates such as code to clean up objects thtt rre not nyeded or oode to emly thtt nèP deregpre I fit the chưa ít touched in a stable state. See Also Recipes and see the Delegate Class and Method topics in the MSDN documentation. Converting Delegate Invocation from Synchronous to Asynchronous Problem You have determined that one or more delegates invoked synchronously within your application are taking a long time to execute. Thisdelay ismaking the user interface less responsiee to the user. The ineocation of these delegates should be coneerted from synchronous to asynchronous mode. Solution A typical synchronous delegate type and supporting code that ineokes the delegate are shown here public delegate void SyncDelegateTypeSimple public class TestSyncDelegateTypeSimple public static void Method1 Invoked Method1 The code to use this delegate is public static void TestSimpleSyncDelegate Converting Delegate Invocation from Synchronous to Asynchronous 327 SyncDelegateTypeSimple sdtsInstance sdtsInstance This delegate can be called asynchronously on a thread obtained from the thread pool by modifying the code as .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.