Window Thread Cancellation for UI Responsiveness
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Window suspended animation occurs when a window thread takes too long to process a task, leading to delayed response times and inability to close the window promptly, as existing methods require the backstage thread to finish processing before allowing window closure.
Innovation Solution
Creating a thread class with a member variable to track task cancellation and a member function to initiate a backstage thread, allowing the window thread to close independently while notifying the backstage thread to quit and release memory.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If the window thread processes a task that takes time, then the task processing is completed, but the window interface is not refreshed and there is no response when buttons are clicked
Solution Approach 1:
The patent divides the window thread into two independent threads: the window thread handles UI responsiveness and the backstage thread handles time-consuming tasks. This segmentation allows the window thread to remain responsive while the backstage thread processes tasks, resolving the contradiction between task processing completion and window responsiveness.
2Ease of operation
If the backstage thread processes a task that takes time, then the window suspended animation problem is solved to a certain degree, but the window can only be closed after the backstage thread has finished processing
Solution Approach 1:
The patent introduces a cancellation flag that can be set before the backstage thread finishes processing. When the user initiates window closure, the flag is set to TRUE, allowing the window to close immediately without waiting for the backstage thread to complete its task. This preliminary action resolves the contradiction by enabling window closure while the backstage thread is still processing.
3Loss of information
If the window thread waits for the backstage thread to finish processing, then the processing result can be returned, but the window closure response is delayed
Solution Approach 1:
The patent implements dynamic control of the backstage thread through a cancellation flag that changes state based on user actions. The flag is FALSE during normal operation, allowing result return, and can be set to TRUE when closure is requested, enabling immediate window closure. This dynamic mechanism resolves the contradiction between returning processing results and enabling timely window closure.
Data Source
AI summary
A method and a device for processing a window task are provided. The method includes: creating a thread class including a first member variable for representing whether a task processed currently has been cancelled and a first member function for initiating a backstage thread; creating a backstage thread object based on the thread class when a task that takes time needs to be processed, and initializing the first member variable in the backstage thread object as FALSE, invoking the first member function in the backstage thread object to initiate the backstage thread; in process of the backstage thread processing the task that takes time, if a close instruction for a current window is received, setting the first member variable in the backstage thread object as TRUE to release the memory space occupied by the backstage thread object and closing the current window.


