XMLTask.SuspendRequired 属性

定义

获取或设置一个布尔值,该值指示在遇到断点时任务是否应挂起。 遇到断点时,将由任务和容器的运行时引擎设置此值。

public:
 property bool SuspendRequired { bool get(); void set(bool value); };
public bool SuspendRequired { get; set; }
member this.SuspendRequired : bool with get, set
Public Property SuspendRequired As Boolean

属性值

Boolean

如果任务挂起,则为 true。

实现

示例

下面的代码示例是自定义任务的重写属性的示例 SuspendRequired

public bool SuspendRequired   
{  
     get  
    {   
        // m_suspendRequired is an Private integer declared in the custom task.   
        return m_suspendRequired != 0;   
    }  

    set  
    {  
    // This lock is also taken by Suspend().  Since it is possible for the package to be   
    // suspended and resumed in quick succession, this property "put" might happen   
    // before the actual Suspend() call.  Without the lock, the Suspend() might reset   
    // the canExecute event after we set it to abort the suspension.   
         lock (this)   
    {  
        Interlocked.Exchange(ref m_suspendRequired, value ? 1 : 0);   
            if (!value)   
                ResumeExecution();   
    }  
}  
Public ReadOnly Property SuspendRequired() As Boolean  
    Get   
        ' m_suspendRequired is an Private integer declared in the custom task.   
        Return m_suspendRequired <> 0  
     End Get  

Public WriteOnly Property SuspendRequired() As Boolean  
    Set (ByVal Value As Boolean)   
        ' This lock is also taken by Suspend().  Since it is possible for the package to be   
        ' suspended and resumed in quick succession, this property "put" might happen   
       ' before the actual Suspend() call.  Without the lock, the Suspend() might reset  
       ' the canExecute event after it is set to abort the suspension.   
         lock (Me)  
         {  
               Interlocked.Exchange(m_suspendRequired, value ? 1 : 0)   
                     If Not value Then  
                       ResumeExecution()  
                     End If  
             }  
         End Set  
End Property  

注解

未在代码中设置属性。 当遇到断点时,它由任务和容器的运行时设置。

但是, IDTSSuspend 如果编写公开断点的多线程自定义任务,则需要提供此方法的代码,该方法是从类继承的。 如果你的任务是单线程的,这意味着你 Execute 在自定义任务中的实现不会启动新线程,则无需实现此接口。 有关编写自定义任务的详细信息,请参阅 开发自定义任务

适用于