语言

ScriptTask.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

属性值

如果任务在遇到断点时暂停执行,则为真;否则,就是假的。

实现

示例

以下代码示例展示了如何覆盖自定义任务的该 SuspendRequired 属性。

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

    set  
    {  
    // This lock is also taken by Suspend().  Because it is possible for the package to be   
    // suspended and resumed in quick succession, this property "set" 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 a 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().  Because 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 (Me)  
         {  
               Interlocked.Exchange(m_suspendRequired, value ? 1 : 0)   
                     If Not value Then  
                       ResumeExecution()  
                     End If  
             }  
         End Set  
End Property  

注解

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

然而,如果你编写了一个暴露断点的多线程自定义任务,你必须为该方法提供代码,该代码是继承自 IDTSSuspend 多线程对象类。 如果你的任务是单线程的,也就是说自定义任务中的实现 Execute 不会启动新线程,你就不必实现这个接口。 关于编写自定义任务的更多信息,请参见 “开发自定义任务”。

适用于