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

属性值

如果任务遇到断点时挂起执行,则为 true;否则为 false。

实现

示例

下面的代码示例演示如何重写 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 不会启动新线程,则无需实现此接口。 有关编写自定义任务的详细信息,请参阅 开发自定义任务

适用于