Dela via


TaskHost Class

Provides a container that encapsulates a single task. In the SSIS Designer, the TaskHost is not configured separately; instead, it is configured when you set the properties of the task it encapsulates.

Inheritance Hierarchy

System.Object
  Microsoft.SqlServer.Dts.Runtime.DtsObject
    Microsoft.SqlServer.Dts.Runtime.Executable
      Microsoft.SqlServer.Dts.Runtime.DtsContainer
        Microsoft.SqlServer.Dts.Runtime.EventsProvider
          Microsoft.SqlServer.Dts.Runtime.TaskHost

Namespace:  Microsoft.SqlServer.Dts.Runtime
Assembly:  Microsoft.SqlServer.ManagedDTS (in Microsoft.SqlServer.ManagedDTS.dll)

Syntax

'Declaration
Public NotInheritable Class TaskHost _
    Inherits EventsProvider _
    Implements IDTSObjectHost, IDTSPropertiesProvider, IDTSPackagePath
'Usage
Dim instance As TaskHost
public sealed class TaskHost : EventsProvider, 
    IDTSObjectHost, IDTSPropertiesProvider, IDTSPackagePath
public ref class TaskHost sealed : public EventsProvider, 
    IDTSObjectHost, IDTSPropertiesProvider, IDTSPackagePath
[<SealedAttribute>]
type TaskHost =  
    class
        inherit EventsProvider
        interface IDTSObjectHost
        interface IDTSPropertiesProvider
        interface IDTSPackagePath
    end
public final class TaskHost extends EventsProvider implements IDTSObjectHost, IDTSPropertiesProvider, IDTSPackagePath

The TaskHost type exposes the following members.

Properties

  Name Description
Public property ApartmentThreaded Infrastructure.
Public property CreationName Returns the string that is used to create an instance of the DtsContainer object. This property is read-only. (Inherited from DtsContainer.)
Public property DebugMode Gets or sets a Boolean that indicates whether the DtsContainer object is in debug mode and whether it should fire the OnBreakpointHit event while running. (Inherited from DtsContainer.)
Public property DelayValidation Gets or sets a Boolean that indicates whether validation of the task is delayed until run time. The default value is false. (Inherited from DtsContainer.)
Public property Description Gets or sets the description of the DtsContainer object. (Inherited from DtsContainer.)
Public property Disable A Boolean that indicates if the DtsContainer object is disabled. (Inherited from DtsContainer.)
Public property DisableEventHandlers Gets or sets a Boolean that indicates whether the event handlers on task are disabled. (Inherited from EventsProvider.)
Public property EventHandlers Returns a collection of event handler objects. This field is read-only. (Inherited from EventsProvider.)
Public property EventInfos Returns a collection of EventInfo objects. This field is read-only. (Inherited from EventsProvider.)
Public property ExecutionDuration Returns a value that indicates the amount of time that the container spent in execution, in milliseconds. This property is read-only. (Inherited from DtsContainer.)
Public property ExecutionResult Returns a value that indicates the success or failure of the execution of the DtsContainer object. (Inherited from DtsContainer.)
Public property ExecutionStatus Returns a value that indicates the current status of the execution of the DtsContainer object at the time of the call. (Inherited from DtsContainer.)
Public property ExecutionValue Returns the result of the task execution. This property is read-only.
Public property ExecValueVariable Gets or sets the custom Variable that contains the execution results of the task.
Public property FailPackageOnFailure Gets or sets a Boolean that indicates whether the package fails when a child container fails. This property is used on containers, not the package itself. (Inherited from DtsContainer.)
Public property FailParentOnFailure Gets or sets a Boolean that defines whether the parent container fails when a child container fails. (Inherited from DtsContainer.)
Public property ForcedExecutionValue If the ForceExecutionValue property is set to true, gets or sets a value that specifies the optional execution value that the package returns. (Inherited from DtsContainer.)
Public property ForceExecutionResult Gets or sets a DTSForcedExecResult enumeration value that specifies the forced execution result of the container. (Inherited from DtsContainer.)
Public property ForceExecutionValue Gets or sets a Boolean that indicates whether the execution value of the container should be forced to contain a particular value. (Inherited from DtsContainer.)
Public property HostType Gets a value from the DTSObjectHostType enumeration that describes the host of the container. This property is read-only.
Public property ID Returns the ID, which is a GUID, of the DtsContainer. The value is read-only. (Inherited from DtsContainer.)
Public property InnerObject The method used to access the task instance being hosted by the TaskHost.
Public property IsDefaultLocaleID A Boolean that indicates whether the container uses the default locale. This property is read-only. (Inherited from DtsContainer.)
Public property IsolationLevel Gets or sets the isolation level of the transaction in the DtsContainer object. (Inherited from DtsContainer.)
Public property LocaleID Gets or sets an Integer that indicates the Microsoft Win32® localeID to use when the DtsContainer object is executed. (Inherited from DtsContainer.)
Public property LogEntryInfos Returns a LogEntryInfos object. This property is read-only. (Inherited from DtsContainer.)
Public property LoggingMode Gets or sets a valid value from the DTSLoggingMode enumeration that indicates the logging mode of the container. (Inherited from DtsContainer.)
Public property LoggingOptions Returns an object that contains properties that indicates the filtering and logging resource for containers. This property is read-only. (Inherited from DtsContainer.)
Public property MaximumErrorCount Gets or sets an Integer value that indicates the maximum number of errors that can occur before the DtsContainer object stops running. (Inherited from DtsContainer.)
Public property Name Gets or sets the name of the DtsContainer. (Inherited from DtsContainer.)
Public property Parent Returns the parent container. The value is read-only. (Inherited from DtsContainer.)
Public property Properties Returns a DtsProperties collection that contains the properties associated with the task.
Public property Site Infrastructure. (Inherited from DtsContainer.)
Public property StartTime Returns the time that the container began execution. This property is read-only. (Inherited from DtsContainer.)
Public property StopTime Returns the time that the container ended execution. This property is read-only. (Inherited from DtsContainer.)
Public property SuspendRequired Gets or sets a Boolean that indicates if tasks should suspend when they encounter a breakpoint. This value is set by the runtime engine for tasks and containers when a breakpoint is encountered. (Inherited from DtsContainer.)
Public property TransactionOption Gets or sets a DTSTransactionOption enumeration value that indicates whether the container participates in transactions. (Inherited from DtsContainer.)
Public property VariableDispenser Returns a VariableDispenser object so variables associated with the container can be locked. (Inherited from DtsContainer.)
Public property Variables Returns a collection that contains the variables associated with this container. This property is read-only. (Inherited from DtsContainer.)

Top

Methods

  Name Description
Public method AcceptBreakpointManager This method is called by the run-time engine when a task or container is created, and passes it a BreakpointManager manager to allow the task to create, remove, and check the status of breakpoints. This method is called by the runtime and is not used in code. (Inherited from DtsContainer.)
Public method Dispose Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. (Inherited from DtsContainer.)
Public method Equals Determines whether two object instances are equal. (Inherited from DtsObject.)
Public method Execute Runs the application, container, or package as part of a package workflow. (Inherited from DtsContainer.)
Protected method Finalize (Inherited from Object.)
Public method GetExpression Returns the expression for the specified property. Null means no expression is assigned.
Public method GetHashCode Returns the hash code for this instance. (Inherited from DtsObject.)
Public method GetPackagePath Returns the path to the task location.
Public method GetType (Inherited from Object.)
Public method LoadFromXML This method is not callable by your application code. To load a package saved as .xml, use the Application.LoadPackage method. (Inherited from DtsContainer.)
Protected method MemberwiseClone (Inherited from Object.)
Public method ResumeExecution Resumes execution of the task after pausing. The task or container is resumed by the runtime engine. (Inherited from DtsContainer.)
Public method SaveToXML This method is not callable by your application code. To save a package as .xml, use the Application.SaveToXml method. (Inherited from DtsContainer.)
Public method SetExpression Assigns the specified expression to the property. Specify nulla null reference (Nothing in Visual Basic) to remove an existing expression from the property.
Protected method SetWrappedExecutable Infrastructure. (Inherited from EventsProvider.)
Public method SuspendExecution Called when the executable needs to suspend. This method is called by the runtime engine. (Inherited from DtsContainer.)
Public method ToString (Inherited from Object.)
Public method Validate Allows the container to determine if it contains invalid settings that will prevent it from executing successfully. (Inherited from DtsContainer.)

Top

Events

  Name Description
Public event Disposed Adds an event handler to listen to the Disposed event on the component. (Inherited from DtsContainer.)

Top

Fields

  Name Description
Protected field m_executable Infrastructure. (Inherited from Executable.)

Top

Remarks

Integration Services provides several different types of containers for building packages, with the TaskHost being one of those containers. The TaskHost container provides services to a single task. It does not have a matching item in the graphical designer toolbox. The TaskHost object is a wrapper object for the task, and is created transparently during task creation. It is returned from the Add method as an Executable object and is cast as a TaskHost. Finally, the task instance is accessed through the InnerObject property. For more information on all of the SSIS containers, see Integration Services Containers.

Examples

The following code example shows the creation of an empty package. Two tasks are added to the package and cast into a TaskHost class, so TaskHost methods and properties can be used on either task , such as the InnerObject method, without regard to what kind of task it is.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Tasks.BulkInsertTask;
using Microsoft.SqlServer.Dts.Tasks.FileSystemTask;

namespace Microsoft.SqlServer.SSIS.Samples
{
    class Program
    {
        static void Main(string[] args)
        {
            Package p = new Package();
            // Add a File System task to the package.
            Executable exec1 = p.Executables.Add("STOCK:FileSystemTask");
            TaskHost thFileSystemTask = exec1 as TaskHost;
            // Add a Bulk Insert task to the package.
            Executable exec2 = p.Executables.Add("STOCK:BulkInsertTask");
            TaskHost thBulkInsertTask = exec2 as TaskHost;

            // Iterate through the package Executables collection.
            Executables pExecs = p.Executables;
            foreach (Executable pExec in pExecs)
            {
                TaskHost taskHost = (TaskHost)pExec;
                Console.WriteLine("Type {0}", taskHost.InnerObject.ToString());
            }
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Tasks.BulkInsertTask
Imports Microsoft.SqlServer.Dts.Tasks.FileSystemTask
 
Namespace Microsoft.SqlServer.SSIS.Samples
    Class Program
        Shared  Sub Main(ByVal args() As String)
            Dim p As Package =  New Package() 
            ' Add a File System task to the package.
            Dim exec1 As Executable =  p.Executables.Add("STOCK:FileSystemTask") 
            Dim thFileSystemTask As TaskHost =  exec1 as TaskHost 
            ' Add a Bulk Insert task to the package.
            Dim exec2 As Executable =  p.Executables.Add("STOCK:BulkInsertTask") 
            Dim thBulkInsertTask As TaskHost =  exec2 as TaskHost 
 
            ' Iterate through the package Executables collection.
            Dim pExecs As Executables =  p.Executables 
            Dim pExec As Executable
            For Each pExec In pExecs
                Dim taskHost As TaskHost = CType(pExec, TaskHost)
                Console.WriteLine("Type {0}", taskHost.InnerObject.ToString())
            Next
        End Sub
    End Class
End Namespace

Sample Output:

Type Microsoft.SqlServer.Dts.Tasks.FileSystemTask.FileSystemTask

Type Microsoft.SqlServer.Dts.Tasks.BulkInsertTask.BulkInsertTask

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.