TaskAbort Method  
 

Abort the specified asynchronous task.

Syntax

object.TaskAbort ( [TaskId], [Milliseconds] )

Parameters

TaskId
An optional integer value that specifies the unique identifier associated with a background task.
Milliseconds
An optional integer value that specifies the number of milliseconds to wait for the background task to abort.

Return Value

A value of zero is returned if the operation was successful, otherwise a non-zero error code is returned which indicates the cause of the failure.

Remarks

The TaskAbort method signals the background worker thread associated with the task ID to abort the current operation and terminate as soon as possible. If the TaskId parameter is omitted, this method will abort all active background file transfers, otherwise it will only abort the specified task. If the Milliseconds parameter is omitted or has a value of zero, the method returns immediately after the background thread has been signaled. If the Milliseconds parameter is non-zero, the method will wait that amount of time for the background thread to terminate.

The Reset and Uninitialize methods will abort all active background transfers and wait for those tasks to complete before returning to the caller. It is recommended that your application explicitly wait for background transfers to complete or abort them using this method before allowing the program to terminate. This will ensure that your program can perform any necessary cleanup operations. If there are active background tasks running at the time that the control instance is destroyed, it can force the control to stop those worker threads immediately without waiting for them to terminate gracefully.

See Also

TaskCount Property, TaskList Property, TaskDone Method, TaskWait Method