Đang chuẩn bị liên kết để tải về tài liệu:
Teach Yourself Visual C++ 6 in21 Days phần 7

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Trước khi bạn có thể quay bất kỳ chủ đề độc lập, chủ đề phải biết phải làm gì. Bạn sẽ tạo ra một chức năng chủ đề chính được thực hiện bởi chủ đề khi nó bắt đầu. Chức năng này sẽ hoạt động như chức năng chính của chủ đề, và các chủ đề sẽ kết thúc khi hàm kết thúc. | Doing Multiple Tasks at One Time Multitasking 461 I Creating the Main Thread Function Before you can spin off any independent threads the thread must know what to do. You will create a main thread function to be executed by the thread when it starts. This function will act as the main function for the thread and the thread will end once the function ends. Therefore this function must act as the primary control of the thread keeping the thread running as long as there is work for the thread to do and then exiting once the thread s work is completed. When you create a function to be used as the main function for a thread you can pass a single parameter to this function. This parameter is a pointer to anything that contains all the information the thread needs to perform its tasks. For the application you ve been building in this chapter the parameter can be a pointer to the spinner that the thread will operate. Everything else that the thread needs can be extracted from the spinner object. Once the thread has a pointer to its spinner it can get a pointer to the check box variable that tells it whether to continue spinning or stop itself. As long as the variable is TRUE the thread should continue spinning. To add this function to your application add a new member function to the document class in your application. Specify the function type as UINT the function declaration as ThreadFunc LPVOID pParam and the access as private. You ll start the thread from within the document class so there s no need for any other classes to see this function. Once you ve added this function edit it with the code in Listing 18.14. Listing 18.14. The CTaskingDoc ThreadFunc FUNCTION. 18 1 UINT CTaskingDoc ThreadFunc LPVOID pParam 2 3 Convert the argument to a pointer to the 4 spinner for this thread 5 CSpinner IpSpin CSpinner pParam 6 Get a pointer to the continuation flag 7 BOOL pbContinue lpSpin- GetContinue 8 9 Loop while the continue flag is true 10 while pbContinue 11 Spin the .

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.