ScriptTask.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;否則為 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 在自訂工作中的執行不會啟動新的執行緒,您就不需要執行這個介面。 如需撰寫自訂工作的詳細資訊,請參閱 開發自訂工作。