BulkInsertTask.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
属性值
如果任务在遇到断点时会暂停,则为真。
实现
示例
以下代码示例是自定义任务被覆盖 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 不会启动新线程,那么你就不需要实现这个接口。 关于编写自定义任务的更多信息,请参见 “开发自定义任务”。