共用方式為


Task Constructor

Definition

Initializes a new instance of the Task class.

protected:
 Task();
protected Task ();
Protected Sub New ()

Examples

The following code sample creates a new BulkInsertTask by using the constructor.

BulkInsertTask myTask = new BulkInsertTask();  
Dim myTask As BulkInsertTask =  New BulkInsertTask()  

Remarks

For tasks that inherit from Task, the code example in the Example section of each task shows how to call the task constructor. However, in most cases, you will be creating the task as a member of a package. For more information on casting the task, see the remarks in Add.

Package pkg = new Package();  
Executable exec1 = pkg.Executables.Add("STOCK:BulkInsertTask");  
TaskHost th = exec1 as TaskHost;  
// You can cast the InnerObject of the TaskHost  
// to the specific class.  
// For the code samples, the task properties are accessed using  
// the Properties of the TaskHost.  
//BulkInsertTask myTask = th.InnerObject as BulkInsertTask;  
Dim pkg As Package =  New Package()   
Dim exec1 As Executable =  pkg.Executables.Add("STOCK:BulkInsertTask")   
Dim th As TaskHost =  exec1 as TaskHost   
' You can cast the InnerObject of the TaskHost  
' to the specific class.  
' For the code samples, the task properties are accessed using  
' the Properties of the TaskHost.  
'BulkInsertTask myTask = th.InnerObject as BulkInsertTask;  

The properties and methods of the BulkInsertTask are available using the TaskHost variable, th.

Applies to