TAILIEUCHUNG - Apress-Visual CSharp 2010 Recipes A Problem Solution Approach_3

Để hoàn thành một hoạt động không đồng bộ bắt đầu bằng cách sử dụng BeginInvoke, bạn gọi phương thức . Các phương pháp BeginInvoke và EndInvoke tạo nên một mô hình không đồng bộ thực hiện phổ biến được biết đến với tên gọi là mô hình Async cổ điển. | CHAPTER 7 WINDOWS FORMS synchronously and BeginInvoke executes the delegate asynchronously. To complete an asynchronous operation initiated using BeginInvoke you call the method. The BeginInvoke and EndInvoke methods make up a common asynchronous execution pattern known as the Classic Async pattern. The details of this pattern and the options you have available for handling method completion are discussed in recipe 4-2. The Code The following example shows how to update a Windows Forms control from multiple threads. The example uses two timers that fire at differing intervals to change the color of a Button control between red and green. The code shows how to use both an anonymous method and a lambda expression with the Invoke call. Both approaches use a delegate type that can encapsulate any method that returns void and takes no arguments. using System using using using using using using namespace public partial class Recipe07_19 Form Declare timers that change the button color. greenTimer redTimer public Recipe07_19 . . Initialization code is designer generated and contained in a separate file named . InitializeComponent Create autoreset timers that fire at varying intervals to change the color of the button on the form. greenTimer new 3000 new greenTimer_Elapsed redTimer new 5000 new redTimer_Elapsed 355 CHAPTER 7 WINDOWS FORMS void redTimer_Elapsed object sender e . Use an anonymous method to set the button color to red. Action delegate void greenTimer_Elapsed object sender .

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.