SetLocalTickCount 方法
設定擁有這個知識之複寫的滴答計數。
命名空間: Microsoft.Synchronization
組件: Microsoft.Synchronization (在 Microsoft.Synchronization.dll 中)
語法
'宣告
Public Sub SetLocalTickCount ( _
localTickCount As ULong _
)
'用途
Dim instance As SyncKnowledge
Dim localTickCount As ULong
instance.SetLocalTickCount(localTickCount)
public void SetLocalTickCount(
ulong localTickCount
)
public:
void SetLocalTickCount(
unsigned long long localTickCount
)
member SetLocalTickCount :
localTickCount:uint64 -> unit
public function SetLocalTickCount(
localTickCount : ulong
)
參數
- localTickCount
型別:System. . :: . .UInt64
擁有這個知識之複寫的目前滴答計數。
例外
例外狀況 | 條件 |
---|---|
InvalidOperationException | 這個 SyncKnowledge 物件尚未初始化。 |
備註
在知識傳送至另一個複寫之前,此滴答計數必須處於最新狀態。一般而言,雖然這個方法可隨時呼叫,但是提供者會在傳送其知識之前立即呼叫這個方法。
範例
下列範例會將 SyncKnowledge 物件的滴答計數設定為本機滴答計數,然後再將它傳回給呼叫者。
Public Overrides Function GetKnowledge() As SyncKnowledge
' If the replica does not yet contain any knowledge, create a new knowledge object.
If _knowledge Is Nothing Then
_knowledge = New SyncKnowledge(IdFormats, ReplicaId, _tickCount)
End If
' Ensure the tick count of the knowledge is set to the current tick count of the replica.
_knowledge.SetLocalTickCount(_tickCount)
Return _knowledge
End Function
public override SyncKnowledge GetKnowledge()
{
// If the replica does not yet contain any knowledge, create a new knowledge object.
if (null == _knowledge)
{
_knowledge = new SyncKnowledge(IdFormats, ReplicaId, _tickCount);
}
// Ensure the tick count of the knowledge is set to the current tick count of the replica.
_knowledge.SetLocalTickCount(_tickCount);
return _knowledge;
}