/// <summary> /// Suspend the document and resumes it periodically, for a time span of 1 second. /// Sometimes, depending on the probabilityToResumeTemporarily, the document is resumed temporarily. /// </summary> public void Worker() { var start = DateTime.UtcNow; do { System.Threading.Thread.Sleep(1); if (null == _suspendToken) { _suspendToken = _doc.SuspendGetToken(); } else { var rnd = _rnd.NextDouble(); if (rnd < _probabilityToResumeTemporarily) { _suspendToken.ResumeCompleteTemporarily(); } else { _suspendToken.Dispose(); _suspendToken = null; } } } while ((DateTime.UtcNow - start).TotalSeconds < 1); if (null != _suspendToken) { _suspendToken.Dispose(); _suspendToken = null; } }
/// <summary> /// Decrease the suspend level by disposing the suppress token. The token will fire the Resume event /// if the suppress level falls to zero. /// </summary> /// <param name="token"></param> /// <returns>The event count accumulated during the suspend phase.</returns> public int Resume(ref ISuspendToken token) { int result = 0; if (token != null) { token.Dispose(); // the OnResume function is called from the SuppressToken token = null; } return result; }
/// <summary> /// Decrease the suspend level by disposing the suppress token. The token will fire the Resume event /// if the suppress level falls to zero. /// </summary> /// <param name="token"></param> /// <returns>The event count accumulated during the suspend phase.</returns> public int Resume(ref ISuspendToken token) { int result = 0; if (token != null) { token.Dispose(); // the OnResume function is called from the SuppressToken token = null; } return(result); }
/// <summary> /// Decrease the suspend level by disposing the suppress token. The token will fire the Resume event /// if the suppress level falls to zero. You can suppress the resume event by setting argument 'suppressResumeEvent' to true. /// </summary> /// <param name="token"></param> /// <param name="firingOfResumeEvent">Designates whether or not to fire the resume event.</param> /// <returns>The event count accumulated during the suspend phase.</returns> public int Resume(ref ISuspendToken token, EventFiring firingOfResumeEvent) { int result = 0; if (token != null) { if (firingOfResumeEvent == EventFiring.Suppressed) { token.ResumeSilently(); } token.Dispose(); // the OnResume function is called from the SuppressToken token = null; } return(result); }
public override bool Deactivate() { var obj = (ClosedCardinalSpline)GraphObject; using (var token = obj.SuspendGetToken()) { int otherPointIndex = _pointNumber == 0 ? 1 : 0; PointD2D oldOtherPointCoord = obj._transformation.TransformPoint(obj._curvePoints[otherPointIndex] + _offset); // transformiere in ParentCoordinaten // Calculate the new Size obj.CalculateAndSetBounds(); obj.UpdateTransformationMatrix(); PointD2D newOtherPointCoord = obj._transformation.TransformPoint(obj._curvePoints[otherPointIndex] + obj.Location.AbsoluteVectorPivotToLeftUpper); obj.ShiftPosition(oldOtherPointCoord - newOtherPointCoord); } _suspendToken?.Dispose(); _suspendToken = null; return(false); }
/// <summary> /// Decrease the suspend level by disposing the suppress token. The token will fire the Resume event /// if the suppress level falls to zero. You can suppress the resume event by setting argument 'suppressResumeEvent' to true. /// </summary> /// <param name="token"></param> /// <param name="firingOfResumeEvent">Designates whether or not to fire the resume event.</param> /// <returns>The event count accumulated during the suspend phase.</returns> public int Resume(ref ISuspendToken token, EventFiring firingOfResumeEvent) { int result = 0; if (token != null) { if (firingOfResumeEvent == EventFiring.Suppressed) { token.ResumeSilently(); } token.Dispose(); // the OnResume function is called from the SuppressToken token = null; } return result; }