Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities.DurableInstancing / System / Activities / DurableInstancing / LoadRetryAsyncResult.cs / 1305376 / LoadRetryAsyncResult.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities.DurableInstancing { using System; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Runtime; using System.Runtime.DurableInstancing; class LoadRetryAsyncResult : AsyncResult { static AsyncCallback onTryCommandCallback = Fx.ThunkCallback(new AsyncCallback(OnTryCommandCallback)); bool commandSuccess; TimeoutHelper commandTimeout; InstanceLockedException lastInstanceLockedException; int retryCount; public LoadRetryAsyncResult(SqlWorkflowInstanceStore store, InstancePersistenceContext context, InstancePersistenceCommand command, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state) { this.InstanceStore = store; this.InstancePersistenceContext = context; this.InstancePersistenceCommand = command; this.commandTimeout = new TimeoutHelper(timeout); InstanceStore.BeginTryCommandInternal(this.InstancePersistenceContext, this.InstancePersistenceCommand, this.commandTimeout.RemainingTime(), LoadRetryAsyncResult.onTryCommandCallback, this); } public SqlWorkflowInstanceStore InstanceStore { get; private set; } public TimeSpan RetryTimeout { get; private set; } InstancePersistenceCommand InstancePersistenceCommand { get; set; } InstancePersistenceContext InstancePersistenceContext { get; set; } public static bool End(IAsyncResult result) { LoadRetryAsyncResult thisPtr = AsyncResult.End(result); return thisPtr.commandSuccess; } public void AbortRetry() { Fx.Assert(this.lastInstanceLockedException != null, "no last instance lock exception"); this.Complete(false, this.lastInstanceLockedException); } public void Retry() { InstanceStore.BeginTryCommandInternal(this.InstancePersistenceContext, this.InstancePersistenceCommand, this.commandTimeout.RemainingTime(), LoadRetryAsyncResult.onTryCommandCallback, this); } [SuppressMessage(FxCop.Category.Design, FxCop.Rule.DoNotCatchGeneralExceptionTypes, Justification = "Standard AsyncResult callback pattern.")] static void OnTryCommandCallback(IAsyncResult result) { LoadRetryAsyncResult tryCommandAsyncResult = (LoadRetryAsyncResult)(result.AsyncState); Exception completeException = null; bool completeFlag = true; try { tryCommandAsyncResult.CompleteTryCommand(result); } catch (InstanceLockedException instanceLockedException) { TimeSpan retryDelay = tryCommandAsyncResult.InstanceStore.GetNextRetryDelay(++tryCommandAsyncResult.retryCount); if (retryDelay < tryCommandAsyncResult.commandTimeout.RemainingTime()) { tryCommandAsyncResult.RetryTimeout = retryDelay; if (tryCommandAsyncResult.InstanceStore.EnqueueRetry(tryCommandAsyncResult)) { tryCommandAsyncResult.lastInstanceLockedException = instanceLockedException; completeFlag = false; } } else if (TD.LockRetryTimeoutIsEnabled()) { TD.LockRetryTimeout(tryCommandAsyncResult.commandTimeout.OriginalTimeout.ToString()); } if (completeFlag) { completeException = instanceLockedException; } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } completeException = exception; } if (completeFlag) { tryCommandAsyncResult.Complete(false, completeException); } } void CompleteTryCommand(IAsyncResult result) { this.commandSuccess = this.InstanceStore.EndTryCommand(result); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TaiwanLunisolarCalendar.cs
- DataGridViewRowPostPaintEventArgs.cs
- LineInfo.cs
- ListViewItemMouseHoverEvent.cs
- DefaultWorkflowLoaderService.cs
- _Semaphore.cs
- WindowPatternIdentifiers.cs
- translator.cs
- ObjectListCommandCollection.cs
- HttpFileCollectionWrapper.cs
- MessageParameterAttribute.cs
- KeyEvent.cs
- NegationPusher.cs
- SqlConnectionHelper.cs
- UrlPath.cs
- BitmapEffectGeneralTransform.cs
- WebPartCancelEventArgs.cs
- ConfigurationStrings.cs
- shaperfactory.cs
- DialogWindow.cs
- TextTreeObjectNode.cs
- Walker.cs
- ClientFormsAuthenticationMembershipProvider.cs
- WebReferencesBuildProvider.cs
- HttpModulesSection.cs
- SharedPersonalizationStateInfo.cs
- BitmapEffectDrawing.cs
- EntityDataSourceSelectingEventArgs.cs
- Trace.cs
- BmpBitmapDecoder.cs
- MessageDecoder.cs
- _AcceptOverlappedAsyncResult.cs
- FilterQuery.cs
- CaseInsensitiveOrdinalStringComparer.cs
- PolyQuadraticBezierSegment.cs
- ColorAnimationBase.cs
- GridViewSelectEventArgs.cs
- PeerNearMe.cs
- TextEditorDragDrop.cs
- IPCCacheManager.cs
- RegexMatch.cs
- TemplateParser.cs
- ServiceOperationParameter.cs
- BamlVersionHeader.cs
- CodeDelegateInvokeExpression.cs
- UserPreferenceChangedEventArgs.cs
- ArraySegment.cs
- ConnectionProviderAttribute.cs
- XamlVector3DCollectionSerializer.cs
- ItemChangedEventArgs.cs
- ParameterElement.cs
- Accessible.cs
- TargetConverter.cs
- SimpleWorkerRequest.cs
- ExeContext.cs
- DbDataSourceEnumerator.cs
- Executor.cs
- RayHitTestParameters.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- SerializationAttributes.cs
- EntityDataSourceWrapper.cs
- SmiRecordBuffer.cs
- ColorAnimationBase.cs
- Parameter.cs
- LinqDataSourceDeleteEventArgs.cs
- TableLayoutRowStyleCollection.cs
- NGCSerializer.cs
- AuthenticationManager.cs
- Transform3DGroup.cs
- QueryCursorEventArgs.cs
- ThicknessKeyFrameCollection.cs
- CombinedGeometry.cs
- CalendarDay.cs
- XPathDocumentNavigator.cs
- SafeNativeMethods.cs
- Axis.cs
- UnsafeNativeMethods.cs
- CodeMethodReturnStatement.cs
- ReadOnlyDictionary.cs
- ContainerUtilities.cs
- DataControlCommands.cs
- ImageIndexConverter.cs
- TransformedBitmap.cs
- ClientConfigurationSystem.cs
- TextShapeableCharacters.cs
- recordstatescratchpad.cs
- SettingsPropertyNotFoundException.cs
- SessionSwitchEventArgs.cs
- httpapplicationstate.cs
- KnownIds.cs
- ImmutableObjectAttribute.cs
- Models.cs
- TimelineClockCollection.cs
- StaticDataManager.cs
- SecurityIdentifierConverter.cs
- GenerateScriptTypeAttribute.cs
- FormatVersion.cs
- QueryOperationResponseOfT.cs
- BitmapCodecInfo.cs
- QueryOptionExpression.cs