IDTSSuspend.SuspendRequired 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个布尔值,该值指示任务在遇到断点时是否应挂起。 遇到断点时,将由任务和容器的运行时引擎设置此值。
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。
示例
下面的代码示例是自定义任务的重写 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 不会启动新线程,则无需实现此接口。 有关编写自定义任务的详细信息,请参阅 开发自定义任务。