Task suspension method and device, computer equipment, storage medium and program product

By querying the abort flag at the target framework level, the intrusiveness of scheduled task interruptions to business logic in traditional technologies is resolved, enabling flexible and controllable task management and reducing the need for business code modifications.

CN120892151APending Publication Date: 2025-11-04KINGDEE SOFTWARE(CHINA) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510983203.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-16
Publication Date
2025-11-04

AI Technical Summary

Technical Problem

In traditional technologies, interrupting scheduled tasks requires secondary development on the business code, which leads to strong intrusion into the business logic and insufficient flexibility and control over task management.

Method used

By querying the termination flag of the target task at the target framework level, the background running task can be terminated, avoiding direct modification of the business code. By injecting the termination flag query logic into the target framework, the intrusion of the business logic is reduced and the flexibility and controllability of task management are improved.

Benefits of technology

It effectively reduces the intrusion into business logic, reduces the workload of adapting business modules, improves the flexibility and controllability of task management, and ensures that tasks can be terminated in accordance with unified framework rules.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120892151A_ABST
    Figure CN120892151A_ABST
Patent Text Reader

Abstract

The invention relates to a task suspension method and device, computer equipment, a storage medium and a program product. The method comprises the steps of executing a target task; under the condition that the target task is the background operation task, calling a target framework corresponding to the target task to query a suspension identifier corresponding to the target task; and stopping executing the target task under the condition that the stopping identifier is the first identifier. By adopting the method, the invasiveness to service logic can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a task termination method, apparatus, computer equipment, storage medium, and program product. Background Technology

[0002] With the development of computer technology, program products can execute scheduled tasks to automatically perform tasks at predetermined times or periodically, thereby improving the operating efficiency and reliability of program products.

[0003] In traditional technologies, implementing the interruption of a scheduled task on top of an existing scheduled task framework in a program product requires secondary development on the business code of the scheduled task, which means that the business code of the scheduled task needs to be modified, making it too intrusive to the business code. Summary of the Invention

[0004] Therefore, it is necessary to provide a task termination method, apparatus, computer device, storage medium, and program product that can reduce the intrusion into business logic in response to the above-mentioned technical problems.

[0005] Firstly, this application provides a method for terminating a task. The method includes:

[0006] Perform the target task;

[0007] If the target task is a background task, call the target framework corresponding to the target task to query the abort flag of the target task.

[0008] If the abort flag is set to the first flag, the execution of the target task will be suspended.

[0009] Secondly, this application also provides a task abort device. The device includes:

[0010] The execution module is used to execute the target task;

[0011] The calling module is used to call the target framework corresponding to the target task to query the abort flag of the target task when the target task is a background running task;

[0012] The abort module is used to abort the execution of the target task when the abort flag is set to the first flag.

[0013] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of any of the methods in the first aspect.

[0014] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the methods in the first aspect.

[0015] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the methods in the first aspect.

[0016] The aforementioned task termination methods, devices, computer equipment, storage media, and computer program products execute the target task. When the target task is a background running task, the corresponding target framework is invoked to query the termination identifier of the target task. If the termination identifier is the first identifier, the execution of the target task is terminated. For target tasks that are in execution and are background running tasks, the termination identifier of the target task is queried by invoking the corresponding target framework. This injects termination identifier query logic at the framework level, allowing the query of the termination identifier of the target task by invoking the target framework. This avoids modifying the business code of the target task, effectively reducing the intrusion into the business logic and the workload of adapting business modules. When the termination identifier is the first identifier, the execution of the target task can be terminated in a timely manner during the execution process, ensuring that the task can be terminated according to unified framework rules. Compared to relying on explicit polling or manual termination in business code, this further improves the flexibility and controllability of task management. Attached Figure Description

[0017] Figure 1 This is a diagram illustrating the application environment of a task termination method in one embodiment.

[0018] Figure 2 This is a flowchart illustrating a task termination method in one embodiment;

[0019] Figure 3 This is a flowchart illustrating the process of suspending the identifier query step in one embodiment;

[0020] Figure 4 This is a flowchart illustrating the process of suspending the identifier update step in one embodiment;

[0021] Figure 5 This is a schematic diagram of the user interface in one embodiment;

[0022] Figure 6 This is a flowchart illustrating a task termination method in one embodiment;

[0023] Figure 7 This is a structural block diagram of a task termination device in one embodiment;

[0024] Figure 8This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0025] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0026] The task termination method provided in this application embodiment can be applied to, for example, Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or placed on a cloud or other network server. Both the terminal and the server can be used independently to execute the task termination method provided in this embodiment. The terminal and server can also work together to execute the task termination method provided in this embodiment. For example, terminal 102 executes a target task; if the target task is a background running task, it calls the target framework corresponding to the target task to query the termination identifier corresponding to the target task; if the termination identifier is the first identifier, it terminates the execution of the target task. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can be smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can be smartwatches, smart bracelets, head-mounted devices, etc. Server 104 can be implemented using a standalone server or a server cluster composed of multiple servers.

[0027] In one embodiment, such as Figure 2 As shown, a task termination method is provided. This embodiment uses the application of this method to a computer device as an example for illustration, including steps 202 to 206.

[0028] Step 202: Execute the target task.

[0029] The target task refers to the task that needs to be executed currently. A target task can be either a background task or a foreground task. A background task is one that is automatically scheduled and executed; it can be understood as a task that does not require user interaction to trigger its execution, such as scheduled tasks, message queue consumption tasks, and data backup tasks. A foreground task is one that is triggered by the user, such as an import task triggered when the user clicks the import button, or a batch operation task triggered by the user on the user interface.

[0030] For example, a computer device performs a target task.

[0031] Step 204: If the target task is a background running task, call the target framework corresponding to the target task to query the abort flag of the target task.

[0032] Among them, the target framework refers to the framework corresponding to the target task. The framework is a set of program components that uniformly encapsulate common basic functions, providing infrastructure support and process management capabilities for the operation of business code, and is responsible for coordinating the task lifecycle, resource scheduling, and exception handling and other common functions.

[0033] For example, the computer device obtains the task description information of the target task, determines the task type based on the task description information, and if the task type is a background running task, determines the target framework corresponding to the target task, and queries the abort flag corresponding to the target task through the target framework. Here, the task description information refers to a set of information describing the attributes, characteristics, and execution requirements of the target task. The task description information includes, but is not limited to, at least one of the following: task identifier, task name, task type, planned execution time, execution cycle, business parameters, configuration information, priority level, resource requirements, required system resources, task function description, business meaning, failure retry strategy, and compensation logic. The task type refers to the identifier that classifies tasks into different categories according to their operation mode and user interaction characteristics. The task type can be either a background running task or a foreground running task.

[0034] In one embodiment, determining the target framework corresponding to the target task includes: obtaining a mapping table, which includes mapping relationships between multiple sets of candidate task identifiers and candidate framework identifiers; determining the candidate framework identifier corresponding to the target task identifier from the mapping table; and determining the framework corresponding to the candidate framework identifier of the target task identifier as the target framework corresponding to the target task. The mapping table can be a pre-set table, which includes mapping relationships between multiple sets of candidate task identifiers and candidate framework identifiers, and the candidate framework identifier corresponding to the target task identifier can be determined through the mapping table.

[0035] In one embodiment, when the target task is a background running task, calling the target framework corresponding to the target task to query the abort flag of the target task includes: determining the pending task stage that is about to be executed in the target task when the target task is a background running task; and calling the target framework corresponding to the target task to query the abort flag of the target task when the pending task stage is the target task stage. Here, the pending task stage refers to the task stage that is about to be executed. It can be understood that the target task consists of multiple task stages, which are executed in a certain order. The task stage that is about to be executed is the pending task stage. For example, if the target task is a database access task, the database access task includes three task stages: creating a database connection, executing SQL (Structured Query Language), and closing the database connection. The execution order is: creating a database connection, executing SQL, and closing the database connection. If none of the three task stages have been executed, then creating a database connection is the pending task stage; if creating a database connection has been completed, then executing SQL is the pending task stage. The target task stage refers to a pre-set task stage that requires calling the target framework to query the abort flag of the target task. There can be one or more target task stages. For some target task stages, the target framework is called to query the corresponding abort flag before the target task stage is executed. For some target task stages, the target framework is called to query the corresponding abort flag after the target task stage is executed. For some target task stages, the target framework is called to query the corresponding abort flag before the target task stage is executed and after the target task stage is executed. The specific time for calling the target framework to query the corresponding abort flag is set according to different tasks.

[0036] In one embodiment, when the task to be executed is a target task stage, invoking the target framework corresponding to the target task to query the abort identifier of the target task includes: determining the query time corresponding to the target task stage, and based on the query time, invoking the target framework corresponding to the target task to query the abort identifier of the target task. Here, the query time refers to the time when the target framework corresponding to the target task is invoked to query the abort identifier of the target task, and the query time can be at least one of before and after the execution of the target task stage.

[0037] In one embodiment, when the target task is a background running task, invoking the target framework corresponding to the target task to query the termination identifier of the target task includes: invoking the target framework corresponding to the target task, and the target framework querying the termination identifier of the target task from the target storage area. Here, the target storage area refers to a pre-set area used to store termination identifiers, and the target storage area can store the termination identifiers of each task.

[0038] Step 206: If the abort flag is set to the first flag, abort the execution of the target task.

[0039] Here, the first identifier is a marker indicating that the task has been aborted; the first identifier can be true or 1. Aborting the execution of the target task means stopping the execution of the target task during its execution process; that is, interrupting the execution of the target task during its execution.

[0040] For example, if the target frame corresponding to the target task queries the abort identifier corresponding to the target task and finds it to be the first identifier, then the computer device will abort the execution of the target task.

[0041] In one embodiment, if the target frame corresponding to the target task queries and finds the abort identifier for the target task to be a second identifier, the computer device continues to execute the target task. Here, the second identifier is an identifier representing the task being executed, and the second identifier can be false or 0.

[0042] In one embodiment, when the abort identifier is the first identifier, aborting the execution of the target task includes: querying the target framework corresponding to the target task to find that the abort identifier for the target task is the first identifier; the target framework sends an abort signal for the target task to the computer device; the computer device aborts the execution of the target task, triggering task rollback. Task rollback refers to restoring or compensating for the state of the entire task execution process.

[0043] In the above task termination method, for a target task that is in execution and is a background running task, the termination identifier of the target task is queried by calling the target framework corresponding to the target task. That is, the termination identifier query logic is injected at the framework level. By calling the target framework, the termination identifier corresponding to the target task can be queried, thereby avoiding modification of the business code of the target task, effectively reducing the intrusion on the business logic, and reducing the workload of business module adaptation. When the termination identifier is the first identifier, the execution of the target task can be terminated in a timely manner during the execution of the target task, ensuring that the task can be terminated according to the unified framework rules. Compared with relying on explicit polling or manual termination in the business code, this further improves the flexibility and controllability of task management.

[0044] In one embodiment, such as Figure 3 As shown, when the target task is a database access task, the target task is executed; when the target task is a background task, the target framework corresponding to the target task is called to query the termination flag of the target task, including:

[0045] Step 302: Invoke the first framework to execute the target task; the first framework is a database access framework.

[0046] Database access tasks refer to operations performed on a database, including but not limited to reading, writing, updating, and deleting data. The first frame refers to the database access framework, which is used to execute database access tasks and to query the termination flag of the target task after each task phase. The first frame is a multi-database support solution that masks the differences between heterogeneous databases by translating structured SQL statements into SQL statements that can run on a specific target database.

[0047] For example, when the target task is a database access task, the computer device invokes the first frame to execute the target task.

[0048] Step 304: Based on the task description information of the target task, determine the task type of the target task through the first framework.

[0049] For example, the computer device obtains the task description information of the target task through the first frame, and determines the task type in the task description information as the task type of the target task.

[0050] Step 306: When the task type is a background running task, query the termination flag of the target task before and after each task stage through the first framework.

[0051] The various task phases refer to creating a database connection, executing SQL, and closing the database connection.

[0052] For example, when the task type is a background running task, the computer device queries the termination identifier of the target task before and after each task stage of the target task through the first frame.

[0053] In one embodiment, when the task type is a foreground running task, the computer device executes each task stage of the database access task sequentially through the first frame to complete the database access task. That is, when the database access task type is a foreground running task, the first frame sequentially executes creating a database connection, executing SQL, and closing the database connection to complete the database access task. During this process, the abort flag of the database access task is not queried. It can be understood that for foreground running tasks, this task must be completed.

[0054] In one embodiment, when the task type is a background running task, the first framework queries the termination flag of the target task before and after each task stage, including: when the database access task is a background running task, the first framework is invoked; before creating a database connection, the first framework queries the termination flag of the database access task; if the termination flag is the first flag, the database access task is terminated; if the termination flag is the second flag, the database connection is created; after creating the database connection, the termination flag is queried; if the termination flag is the first flag, the database access task is terminated; if the termination flag is the second flag, SQL is executed; after SQL execution, the termination flag is queried; if the termination flag is the first flag, the database access task is terminated; if the termination flag is the second flag, the database connection is closed; after closing the database connection, the termination flag is queried; if the termination flag is the first flag, the database access task is terminated; if the termination flag is the second flag, task completion information is returned.

[0055] In this embodiment, for database access tasks that are background running tasks, the management and detection of database operations can be achieved through the first framework. Compared to modifying the implementation code of the database access task, this effectively reduces the intrusion into business logic and the workload of adapting business modules. Moreover, by injecting abort flag query logic into the first framework, framework-level extension is achieved, improving the flexibility of extension.

[0056] In one embodiment, when the target task is either a file read / write task or a network request task, the target framework corresponding to the target task is invoked to query the abort flag corresponding to the target task, including:

[0057] Before executing the target task phase, the second framework is invoked to query the abort flag corresponding to the target task; the second framework is the security management framework.

[0058] File read / write tasks refer to the tasks of reading or writing files in the file system through file streams. File read / write tasks include at least one of file stream reading and file stream writing. File stream reading refers to sequentially reading data from a file into memory through a file input stream. File stream writing refers to sequentially writing data to a file through a file output stream. Network request tasks refer to the tasks of exchanging data between a program and a remote server. The second framework refers to the security management framework, which can be the Security Manager provided by the Java Development Kit (JDK).

[0059] For example, if the target task is either a file read / write task or a network request task, the second framework is invoked to query the abort flag corresponding to the target task before executing the target task phase.

[0060] In this embodiment, the query for the abort flags of file read / write tasks and network request tasks is implemented through a second framework. Compared to modifying the implementation code of file read / write tasks and network request tasks, this effectively reduces the intrusion into business logic and the workload of adapting business modules. Moreover, by injecting the abort flag query logic into the second framework, framework-level extension is achieved, improving the flexibility of extension.

[0061] In one embodiment, when the target task is a file read / write task, before executing the target task phase, the second framework is invoked to query the abort flag corresponding to the target task, including:

[0062] Before creating the file stream, the second framework is called to query the abort flag corresponding to the target task.

[0063] In this context, a file stream refers to a data channel for reading or writing data.

[0064] For example, when the target task is a file read / write task, the computer device calls the second frame to query the abort flag corresponding to the target task before creating the file stream.

[0065] In one embodiment, before calling the second framework to query the abort flag corresponding to the target task, the method further includes: extending the file read detection (checkRead), file write detection (checkWrite), and network socket connection detection methods in the second framework. The file read detection, file write detection, and network socket connection detection methods are used to query the abort flag of the corresponding task.

[0066] In one embodiment, before calling the second framework to query the abort flag corresponding to the target task, the method further includes: when the second framework provides a security manager for the Java Development Kit, enabling the security manager via the Java Virtual Machine (JVM) parameter -Djava.security.manager when the JVM starts.

[0067] In this embodiment, the abort flag of the file read / write task is queried through a second framework before the file stream is created. Compared to modifying the implementation code of the file read / write task, this effectively reduces the intrusion into the business logic and reduces the workload of adapting business modules. Moreover, by injecting the abort flag query logic into the second framework, framework-level extension is achieved, improving the flexibility of extension.

[0068] In one embodiment, when the target task is a network request task, before executing the target task phase, the second framework is invoked to query the abort flag corresponding to the target task, including:

[0069] Before the socket instance is created, the second framework is called to query the abort flag corresponding to the target task.

[0070] Among them, socket instance creation refers to creating a socket instance (i.e., Socket creation), which is used to initiate network connections.

[0071] For example, when the target task is a network request task, the computer device calls the second frame to query the abort flag corresponding to the target task before the socket instance is created.

[0072] In this embodiment, the abort flag of the network request task is queried through a second framework before the socket instance is created. Compared to modifying the implementation code of the network request task, this effectively reduces the intrusion into the business logic and the workload of adapting business modules. Moreover, by injecting the abort flag query logic into the second framework, framework-level extension is achieved, improving the flexibility of extension.

[0073] In one embodiment, the task abort method further includes:

[0074] Monitor the execution status of the target task; if the execution status is suspended, trigger the compensation logic corresponding to the target task.

[0075] The execution status refers to the state of the target task's execution. The execution status can be one of three: executing, suspended, or completed. Executing means the target task is currently being executed. Suspended execution means the execution of the target task is interrupted, i.e., the target task stops executing after a portion of it has been completed. Completed execution means the target task has been fully executed. Compensation logic refers to the processing logic executed after a task is suspended. It can be understood as additional processing logic executed to restore the system state or avoid data inconsistency after a task is suspended. The functions in the compensation logic include, but are not limited to, data recovery, state correction, resource cleanup, and notification and auditing. The compensation logic can be configured according to actual needs and is not restricted here.

[0076] For example, the computer device monitors the execution status of the target task through a compensation listening event, and triggers the compensation logic corresponding to the target task when the execution status is suspended.

[0077] In this embodiment, the execution status of the target task is monitored by a compensation listening event. When the execution status is suspended, the compensation logic corresponding to the target task is triggered. The logic is freely defined by the business code. A unified task suspension event and compensation mechanism are defined to realize the exception management of task interruption. The context state at the time of task suspension can be retained in a timely manner, providing accurate basic data for post-event tracking and auditing.

[0078] In one embodiment, such as Figure 4 As shown, after executing the target task, the following also includes:

[0079] Step 402: Display the task list; the task list includes the target task identifiers of the target tasks whose running status is "running".

[0080] The task list is a table displaying tasks, including but not limited to task identifier, running status, planned time, start time, end status change time, time elapsed, and execution speed. Running status refers to the task's current state, which can be running, completed, waiting to run, or stopped. For example, a schematic diagram of the user interface is shown below. Figure 5 As shown, the task list includes multiple task identifiers, as well as the running status, planned time, start time, end status change time, time elapsed, and execution speed of each task identifier.

[0081] For example, an operator triggers a task list display operation, and the computer device responds by displaying the task list. For instance, the operator clicks on a task list such as... Figure 5 The diagram shows a background transaction monitoring control in the user interface, where the computer device displays a task list.

[0082] Step 404: In response to the selection trigger operation for the target task identifier, the target task identifier is determined as the selected task identifier.

[0083] Among them, selecting a trigger operation refers to selecting a trigger operation for a task in the task list.

[0084] For example, when an operator selects a target task identifier, the computer device responds to the selection trigger operation for the target task identifier by identifying the target task identifier as the selected task identifier.

[0085] Step 406: In response to the trigger operation for the abort control, the abort flag corresponding to the selected task flag is updated to the first flag.

[0086] Among them, the abort control refers to a functional component used to trigger or control the termination of a task. For example, such as Figure 5 The stop control shown in the schematic diagram of the operation interface.

[0087] For example, after an operator selects a target task identifier, they click the stop control. In response to the trigger operation on the stop control, the computer device updates the stop identifier corresponding to the selected task identifier to the first identifier, that is, updates the stop identifier corresponding to the target task identifier to the first identifier.

[0088] In this embodiment, the operator can update the stop identifier corresponding to the target task identifier to the first identifier by selecting the target task identifier that is running in the task list and clicking the stop control, thus laying the foundation for realizing fine-grained task stop at the task level.

[0089] In one exemplary embodiment, a framework-level extended abort flag detection scheme is provided. In the task created by the product, an abort flag variable can be set. This technical solution, at the framework level, utilizes extensible scenarios (such as common database access, file read / write, and network requests). When the business code runs through these scenarios, the framework automatically performs abort flag detection. If an abort flag is detected, the framework throws an exception, triggers a transaction rollback, and transmits an abort signal to the upper layer, thus achieving the purpose of aborting the task. No explicit polling is required in the business code; the business code requires zero modification, and the framework automatically injects the abort flag detection logic. A flowchart of the task abort method is shown below. Figure 6 As shown, it includes:

[0090] Create a target task, which is a scheduled task.

[0091] Set the abort flag for the target task to false.

[0092] Perform the target task.

[0093] When an operator triggers the task list display operation, the computer device responds by displaying the task list. The operator then selects a target task identifier, and the computer device responds by triggering an operation based on that selection, designating the target task identifier as the selected task identifier. After selecting the target task identifier, the operator clicks the abort control. The computer device responds by triggering an operation based on the abort control, updating the abort identifier corresponding to the selected task identifier to true, thus updating the abort identifier corresponding to the target task identifier to true.

[0094] When the target task is a database access task, based on the task description information, the database access framework determines the task type. If the task type is a background task, the framework queries the abort flag of the database access task before creating a database connection. If the abort flag is true, the database access task is aborted; if it is false, the database connection is created. After creating the database connection, the framework queries the abort flag again. If the flag is true, the database access task is aborted; if it is false, SQL is executed. After SQL execution, the framework queries the abort flag again. If the flag is true, the database access task is aborted; if it is false, the database connection is closed. After closing the database connection, the framework queries the abort flag again. If the flag is true, the database access task is aborted; if it is false, the target task is completed.

[0095] When the target task is either a file read / write task or a network request task, before executing the target task phase, the Security Manager is invoked to query the corresponding abort flag for the target task. Specifically, when the target task is a file read / write task, the Security Manager is invoked to query the corresponding abort flag before creating the file stream; when the target task is a network request task, the computer device invokes the Security Manager to query the corresponding abort flag before creating the socket instance. If the abort flag is true, the Security Manager sends an abort signal to the computer device, which then aborts the target task and triggers a task rollback. If the abort flag is false, the computer device continues executing the target task until it is completed.

[0096] The execution status of the target task is monitored by a compensation listener event. If the execution status is suspended, the compensation logic corresponding to the target task is triggered.

[0097] In the above task termination method, for a target task that is in execution and is a background running task, the termination identifier of the target task is queried by calling the target framework corresponding to the target task. That is, the termination identifier query logic is injected at the framework level. By calling the target framework, the termination identifier corresponding to the target task can be queried, thereby avoiding modification of the business code of the target task, effectively reducing the intrusion on the business logic, and reducing the workload of business module adaptation. When the termination identifier is the first identifier, the execution of the target task can be terminated in a timely manner during the execution of the target task, ensuring that the task can be terminated according to the unified framework rules. Compared with relying on explicit polling or manual termination in the business code, this further improves the flexibility and controllability of task management.

[0098] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0099] Based on the same inventive concept, this application also provides a task termination device for implementing the task termination method described above. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations in one or more task termination device embodiments provided below can be found in the limitations of the task termination method described above, and will not be repeated here.

[0100] In one embodiment, such as Figure 7 As shown, a task termination device is provided, comprising: an execution module 702, a calling module 704, and a termination module 706, wherein:

[0101] Execution module 702 is used to execute the target task;

[0102] Module 707 is invoked to query the abort flag of the target task when the target task is a background running task.

[0103] The abort module 706 is used to abort the execution of the target task when the abort flag is the first flag.

[0104] In one embodiment, the execution module 702 is further configured to: call a first framework to execute the target task; the first framework is a database access framework; the calling module 707 is further configured to: determine the task type of the target task based on the task description information of the target task through the first framework; if the task type is a background running task, query the termination identifier of the target task before and after each task stage of the target task through the first framework.

[0105] In one embodiment, when the target task is either a file read / write task or a network request task, the calling module 707 is further configured to: before executing the target task stage, call the second framework to query the abort flag corresponding to the target task; the second framework is a security management framework.

[0106] In one embodiment, when the target task is a file read / write task, the calling module 707 is further configured to: call the second frame to query the abort flag corresponding to the target task before creating the file stream.

[0107] In one embodiment, when the target task is a network request task, the calling module 707 is further configured to: call the second frame to query the abort flag corresponding to the target task before the socket instance is created.

[0108] In one embodiment, the task termination device further includes a monitoring module, which is used to: monitor the execution status of the target task; and trigger the compensation logic corresponding to the target task when the execution status is terminated.

[0109] In one embodiment, the task termination device further includes an update module, which is configured to: display a task list; the task list includes a target task identifier whose running status is a target task; in response to a selection trigger operation for the target task identifier, determine the target task identifier as the selected task identifier; and in response to a trigger operation for the termination control, update the termination identifier corresponding to the selected task identifier to a first identifier.

[0110] Each module in the aforementioned task termination device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can invoke and execute the operations corresponding to each module.

[0111] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 8As shown, the computer device includes a processor, memory, input / output interface, communication interface, display unit, and input device. The processor, memory, and input / output interface are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interface. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interface is used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a task termination method. The display unit is used to form a visually visible image and can be a display screen, projection device, or virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0112] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0113] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.

[0114] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0115] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0116] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.

[0117] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0118] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0119] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for terminating a task, characterized in that, The method includes: Perform the target task; If the target task is a background running task, the target framework corresponding to the target task is invoked to query the abort identifier corresponding to the target task. If the abort flag is the first flag, the execution of the target task is aborted.

2. The method according to claim 1, characterized in that, When the target task is a database access task, executing the target task includes: The first framework is invoked to execute the target task; the first framework is a database access framework. When the target task is a background running task, the step of calling the target framework corresponding to the target task to query the termination identifier of the target task includes: Based on the task description information of the target task, the task type of the target task is determined through the first framework; When the task type is a background running task, the first framework queries the termination identifier of the target task before and after each task stage of the target task.

3. The method according to claim 1, characterized in that, When the target task is either a file read / write task or a network request task, the step of calling the target framework corresponding to the target task to query the abort identifier corresponding to the target task includes: Before executing the target task phase of the target task, the second framework is invoked to query the abort flag corresponding to the target task; the second framework is a security management framework.

4. The method according to claim 3, characterized in that, When the target task is a file read / write task, the step of calling the second framework to query the abort flag corresponding to the target task before executing the target task stage includes: Before creating the file stream, the second framework is invoked to query the abort flag corresponding to the target task.

5. The method according to claim 3, characterized in that, When the target task is a network request task, the step of calling the second framework to query the abort flag corresponding to the target task before executing the target task stage includes: Before the socket instance is created, the second framework is called to query the abort flag corresponding to the target task.

6. The method according to claim 1, characterized in that, The method further includes: Monitor the execution status of the target task; If the execution status is suspended, the compensation logic corresponding to the target task is triggered.

7. The method according to claim 1, characterized in that, After the execution of the target task, the following is also included: Display a task list; the task list includes target task identifiers whose running status is "running"; In response to the selection trigger operation for the target task identifier, the target task identifier is determined as the selected task identifier; In response to a trigger operation on the abort control, the abort flag corresponding to the selected task flag is updated to the first flag.

8. A task abort device, characterized in that, The device includes: The execution module is used to execute the target task; The calling module is used to call the target framework corresponding to the target task to query the abort identifier of the target task when the target task is a background running task; The abort module is used to abort the execution of the target task when the abort identifier is the first identifier.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.

11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.