SyncKnowledge::SetLocalTickCount Method

Sets the tick count for the replica that owns this knowledge.

Namespace:  Microsoft.Synchronization
Assembly:  Microsoft.Synchronization (in Microsoft.Synchronization.dll)

public:
void SetLocalTickCount(
	unsigned long long localTickCount
)

Parameters

localTickCount
Type: System::UInt64
The current tick count of the replica that owns this knowledge.

ExceptionCondition
InvalidOperationException

This SyncKnowledge object is not initialized.

The tick count must be current before the knowledge is sent to another replica. Typically, a provider calls this method immediately before sending its knowledge; although the method can be called at any time.

The following example sets the tick count of the SyncKnowledge object to the local tick count before returning it to the caller.

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;
}


Show: