Compartir a través de


IDTSSequence.PrecedenceConstraints Property

Returns a collection of PrecedenceConstraint objects associated with the container. This field is read-only.

Espacio de nombres: Microsoft.SqlServer.Dts.Runtime
Ensamblado: Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll)

Sintaxis

'Declaración
ReadOnly Property PrecedenceConstraints As PrecedenceConstraints
PrecedenceConstraints PrecedenceConstraints { get; }
property PrecedenceConstraints^ PrecedenceConstraints {
    PrecedenceConstraints^ get ();
}
/** @property */
PrecedenceConstraints get_PrecedenceConstraints ()
function get PrecedenceConstraints () : PrecedenceConstraints

Valor de propiedad

A PrecedenceConstraints collection that contains PrecedenceConstraint objects for the container.

Notas

Precedence constraints establish the order that executable objects run in a package. The precedence constraint allows the control of execution of the containers and tasks in a package to be based on the result of the execution of a previous task or container. Precedence constraints are established between two Executable objects by calling the Add method of the PrecedenceConstraints collection on the container object. After creating a constraint between two executable objects, the Value property is set to establishes the criteria for executing the second executable defined in the constraint.

Ejemplo

The Package class inherits from IDTSSequence and implements an PrecedenceConstraints collection The following code sample demonstrates adding two tasks to a package. A PrecedenceConstraint is added to the PrecedenceConstraints collection. The constraint created between the tasks prevents the second task from running until the first task completes.

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

namespace DataFlow_Conceptual
{
    class Program
    {
        static void Main(string[] args)
        {
            Package p = new Package();
            // Add a File System task.
            Executable eFileTask1 = p.Executables.Add("STOCK:FileSystemTask");
            TaskHost thFileHost1 = eFileTask1 as TaskHost;

            // Add a second File System task.
            Executable eFileTask2 = p.Executables.Add("STOCK:FileSystemTask");
            TaskHost thFileHost2 = eFileTask2 as TaskHost;

            // Put a precedence constraint between the tasks.
            // Set the constraint to be that thFileTask2 cannot run
            // until thFileTask1 completes.
            PrecedenceConstraint pcFileTasks = p.PrecedenceConstraints.Add((Executable)thFileHost1, (Executable) thFileHost2);
            pcFileTasks.Value = DTSExecResult.Completion;
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Tasks.FileSystemTask
 
Namespace DataFlow_Conceptual
    Class Program
        Shared  Sub Main(ByVal args() As String)
            Dim p As Package =  New Package() 
            ' Add a File System task.
            Dim eFileTask1 As Executable =  p.Executables.Add("STOCK:FileSystemTask") 
            Dim thFileHost1 As TaskHost =  eFileTask1 as TaskHost 
 
            ' Add a second File System task.
            Dim eFileTask2 As Executable =  p.Executables.Add("STOCK:FileSystemTask") 
            Dim thFileHost2 As TaskHost =  eFileTask2 as TaskHost 
 
            ' Put a precedence constraint between the tasks.
            ' Set the constraint to be that thFileTask2 cannot run
            ' until thFileTask1 completes.
            Dim pcFileTasks As PrecedenceConstraint =  p.PrecedenceConstraints.Add(CType(thFileHost1,CType(thFileHost2, Executable, Executable))) 
            pcFileTasks.Value = DTSExecResult.Completion
        End Sub
    End Class
End Namespace

Seguridad para subprocesos

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

Plataformas

Plataformas de desarrollo

Para obtener una lista de las plataformas compatibles, vea Requisitos de hardware y software para instalar SQL Server 2005.

Plataformas de destino

Para obtener una lista de las plataformas compatibles, vea Requisitos de hardware y software para instalar SQL Server 2005.

Vea también

Referencia

IDTSSequence Interface
IDTSSequence Members
Microsoft.SqlServer.Dts.Runtime Namespace