private void ThrowIfUndoGroupOpen()
{
if (undoGroupDepth != 0)
{
undoGroupDepth = 0;
throw new InvalidOperationException("No undo group should be open at this point");
}
if (state != StateListen)
{
throw new InvalidOperationException("This method cannot be called while an undo operation is being performed");
}
}