Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / RunTime / DbRetry.cs / 1305376 / DbRetry.cs
using System; using System.Collections.Generic; using System.Text; using System.Threading; namespace System.Workflow.Runtime { internal class DbRetry { private const short _defaultMaxRetries = 20; private const int _defaultRetrySleep = 2000; private const short _spinCount = 3; private short _maxRetries = _defaultMaxRetries; private int _retrySleep = _defaultRetrySleep; private bool _enableRetries = false; protected DbRetry() { } internal DbRetry(bool enableRetries) { _enableRetries = enableRetries; } internal short MaxRetries { get { return _maxRetries; } } internal bool TryDoRetry(ref short retryCount) { if (CanRetry(retryCount++)) { RetrySleep(retryCount); return true; } else return false; } internal bool CanRetry(short retryCount) { if (!_enableRetries) return false; if (retryCount < _maxRetries) return true; else return false; } internal void RetrySleep(short retryCount) { // // For the first couple of retries just spin // If we fail _spinCount times start then introduce a sleep if (retryCount <= _spinCount) return; int sleep = _retrySleep * retryCount; Thread.Sleep(sleep); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Collections.Generic; using System.Text; using System.Threading; namespace System.Workflow.Runtime { internal class DbRetry { private const short _defaultMaxRetries = 20; private const int _defaultRetrySleep = 2000; private const short _spinCount = 3; private short _maxRetries = _defaultMaxRetries; private int _retrySleep = _defaultRetrySleep; private bool _enableRetries = false; protected DbRetry() { } internal DbRetry(bool enableRetries) { _enableRetries = enableRetries; } internal short MaxRetries { get { return _maxRetries; } } internal bool TryDoRetry(ref short retryCount) { if (CanRetry(retryCount++)) { RetrySleep(retryCount); return true; } else return false; } internal bool CanRetry(short retryCount) { if (!_enableRetries) return false; if (retryCount < _maxRetries) return true; else return false; } internal void RetrySleep(short retryCount) { // // For the first couple of retries just spin // If we fail _spinCount times start then introduce a sleep if (retryCount <= _spinCount) return; int sleep = _retrySleep * retryCount; Thread.Sleep(sleep); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SqlReorderer.cs
- VirtualPathUtility.cs
- PathFigureCollectionConverter.cs
- Fonts.cs
- ColorTranslator.cs
- IPEndPointCollection.cs
- FixedSOMTextRun.cs
- ExtensionSurface.cs
- RangeValuePattern.cs
- ExpressionWriter.cs
- DataReaderContainer.cs
- TimeIntervalCollection.cs
- ValidationSummary.cs
- HttpListenerException.cs
- _LocalDataStore.cs
- ObjectList.cs
- Touch.cs
- MouseBinding.cs
- Helpers.cs
- DataGridItemEventArgs.cs
- DefaultHttpHandler.cs
- EnumValidator.cs
- DataBinding.cs
- RijndaelManagedTransform.cs
- WCFBuildProvider.cs
- ToolStripPanelRenderEventArgs.cs
- FaultContractInfo.cs
- DataBoundControl.cs
- TextOnlyOutput.cs
- DataGridViewEditingControlShowingEventArgs.cs
- ConnectionManagementSection.cs
- ToolboxItemCollection.cs
- HostingEnvironment.cs
- ContextStaticAttribute.cs
- SafeWaitHandle.cs
- ToRequest.cs
- ConsumerConnectionPointCollection.cs
- MimeMultiPart.cs
- Identity.cs
- StandardBindingReliableSessionElement.cs
- ObjectCacheHost.cs
- HotSpot.cs
- ConfigurationSettings.cs
- MeshGeometry3D.cs
- WebPartMinimizeVerb.cs
- ComplusEndpointConfigContainer.cs
- TextBoxAutomationPeer.cs
- IndexedDataBuffer.cs
- Documentation.cs
- ApplicationSecurityManager.cs
- WithStatement.cs
- UIAgentMonitor.cs
- EventProvider.cs
- SortedList.cs
- PointLightBase.cs
- RemoteDebugger.cs
- ActivityScheduledQuery.cs
- GlyphTypeface.cs
- WebRequestModulesSection.cs
- ShapingEngine.cs
- ObjectViewEntityCollectionData.cs
- PageAdapter.cs
- DeobfuscatingStream.cs
- DesignerInterfaces.cs
- DefaultAuthorizationContext.cs
- WindowsListViewGroup.cs
- HttpFileCollectionWrapper.cs
- PermissionSetEnumerator.cs
- EntityParameterCollection.cs
- XmlCharacterData.cs
- hebrewshape.cs
- BitConverter.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- Compensate.cs
- SpotLight.cs
- HtmlTextBoxAdapter.cs
- EmbeddedObject.cs
- XmlTextReaderImplHelpers.cs
- WindowsTokenRoleProvider.cs
- AnimationTimeline.cs
- ChineseLunisolarCalendar.cs
- WsdlServiceChannelBuilder.cs
- MessageQueueException.cs
- ConfigurationSectionGroup.cs
- ByteFacetDescriptionElement.cs
- ReflectionServiceProvider.cs
- NameSpaceEvent.cs
- TableCellAutomationPeer.cs
- SQLDoubleStorage.cs
- TextElementEnumerator.cs
- IdentityModelDictionary.cs
- ContainerParagraph.cs
- WebScriptClientGenerator.cs
- SystemTcpConnection.cs
- FlowPosition.cs
- SqlClientWrapperSmiStream.cs
- TriggerAction.cs
- PrintDocument.cs
- SqlInternalConnectionTds.cs
- DataView.cs