TAILIEUCHUNG - Teach Yourself Visual C++ 6 in 21 Days phần 7

Bây giờ hãy nói rằng bạn cần thiết để tạo ra một nhiệt để sử dụng trong tủ lạnh. Bạn có thể bắt đầu từ đầu và xây dựng một nhiệt tùy chỉnh, hoặc bạn có thể mất nhiệt hiện tại của bạn và xác định phiên bản của tủ lạnh khác từ bản gốc. Những khác biệt này có thể bao gồm rằng đó là hạn chế bật điều hòa không khí | 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 . Listing . 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.