다음을 통해 공유


TaskHost 클래스

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.

네임스페이스:  Microsoft.SqlServer.Dts.Runtime
어셈블리:  Microsoft.SqlServer.ManagedDTS.dll의 Microsoft.SqlServer.ManagedDTS

구문

‘선언
Public NotInheritable Class TaskHost _
    Inherits EventsProvider _
    Implements IDTSObjectHost, IDTSPropertiesProvider, IDTSPackagePath
‘사용 방법
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

주의

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 컨테이너.

예제

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

스레드로부터의 안전성

이 형식의 모든 공용 static(Visual Basic에서는 Shared) 멤버는 스레드로부터 안전합니다. 인스턴스 멤버는 스레드로부터의 안전성이 보장되지 않습니다.