public BookmarkResumptionResult TryGenerateWorkItem(ActivityExecutor executor, ref Bookmark bookmark, BookmarkScope scope, object value, ActivityInstance isolationInstance, bool nonScopedBookmarksExist, out ActivityExecutionWorkItem workItem) { Fx.Assert(scope != null, "We should never have a null sub instance."); BookmarkManager manager = null; workItem = null; BookmarkScope lookupScope = scope; if (scope.IsDefault) { lookupScope = this.defaultScope; } // We don't really care about the return value since we'll // use null to know we should check uninitialized sub instances this.bookmarkManagers.TryGetValue(lookupScope, out manager); if (manager == null) { Fx.Assert(lookupScope != null, "The sub instance should not be default if we are here."); BookmarkResumptionResult finalResult = BookmarkResumptionResult.NotFound; // Check the uninitialized sub instances for a matching bookmark if (this.uninitializedScopes != null) { for (int i = 0; i < this.uninitializedScopes.Count; i++) { BookmarkScope uninitializedScope = this.uninitializedScopes[i]; Fx.Assert(this.bookmarkManagers.ContainsKey(uninitializedScope), "We must always have the uninitialized sub instances."); Bookmark internalBookmark; BookmarkCallbackWrapper callbackWrapper; BookmarkResumptionResult resumptionResult; if (!this.bookmarkManagers[uninitializedScope].TryGetBookmarkFromInternalList(bookmark, out internalBookmark, out callbackWrapper)) { resumptionResult = BookmarkResumptionResult.NotFound; } else if (IsExclusiveScopeUnstable(internalBookmark)) { resumptionResult = BookmarkResumptionResult.NotReady; } else { resumptionResult = this.bookmarkManagers[uninitializedScope].TryGenerateWorkItem(executor, true, ref bookmark, value, isolationInstance, out workItem); } if (resumptionResult == BookmarkResumptionResult.Success) { // We are using InitializeBookmarkScopeWithoutKeyAssociation because we know this is a new uninitialized scope and // the key we would associate is already associated. And if we did the association here, the subsequent call to // FlushBookmarkScopeKeys would try to flush it out, but it won't have the transaction correct so will hang waiting for // the transaction that has the PersistenceContext locked to complete. But it won't complete successfully until // we finish processing here. InitializeBookmarkScopeWithoutKeyAssociation(uninitializedScope, scope.Id); // We've found what we were looking for return BookmarkResumptionResult.Success; } else if (resumptionResult == BookmarkResumptionResult.NotReady) { // This uninitialized sub-instance has a matching bookmark but // it can't currently be resumed. We won't return BookmarkNotFound // because of this. finalResult = BookmarkResumptionResult.NotReady; } else { if (finalResult == BookmarkResumptionResult.NotFound) { // If we still are planning on returning failure then // we'll incur the cost of seeing if this scope is // stable or not. if (!IsStable(uninitializedScope, nonScopedBookmarksExist)) { // There exists an uninitialized scope which is unstable. // At the very least this means we'll return NotReady since // this uninitialized scope might eventually contain this // bookmark. finalResult = BookmarkResumptionResult.NotReady; } } } } } return finalResult; } else { Bookmark bookmarkFromList; BookmarkCallbackWrapper callbackWrapper; BookmarkResumptionResult resumptionResult; if (!manager.TryGetBookmarkFromInternalList(bookmark, out bookmarkFromList, out callbackWrapper)) { resumptionResult = BookmarkResumptionResult.NotFound; } else { if (IsExclusiveScopeUnstable(bookmarkFromList)) { resumptionResult = BookmarkResumptionResult.NotReady; } else { resumptionResult = manager.TryGenerateWorkItem(executor, true, ref bookmark, value, isolationInstance, out workItem); } } if (resumptionResult == BookmarkResumptionResult.NotFound) { if (!IsStable(lookupScope, nonScopedBookmarksExist)) { resumptionResult = BookmarkResumptionResult.NotReady; } } return resumptionResult; } }
public BookmarkResumptionResult TryGenerateWorkItem(ActivityExecutor executor, bool isExternal, ref Bookmark bookmark, object value, ActivityInstance isolationInstance, out ActivityExecutionWorkItem workItem) { Bookmark internalBookmark = null; BookmarkCallbackWrapper callbackWrapper = null; if (!this.TryGetBookmarkFromInternalList(bookmark, out internalBookmark, out callbackWrapper)) { workItem = null; return BookmarkResumptionResult.NotFound; } bookmark = internalBookmark; if (!ActivityUtilities.IsInScope(callbackWrapper.ActivityInstance, isolationInstance)) { workItem = null; // We know about the bookmark, but we can't resume it yet return BookmarkResumptionResult.NotReady; } workItem = callbackWrapper.CreateWorkItem(executor, isExternal, bookmark, value); if (!BookmarkOptionsHelper.SupportsMultipleResumes(callbackWrapper.Options)) { // cleanup bookmark on resumption unless the user opts into multi-resume Remove(bookmark, callbackWrapper); } return BookmarkResumptionResult.Success; }
public BookmarkResumptionResult TryGenerateWorkItem(ActivityExecutor executor, ref Bookmark bookmark, BookmarkScope scope, object value, ActivityInstance isolationInstance, bool nonScopedBookmarksExist, out ActivityExecutionWorkItem workItem) { Fx.Assert(scope != null, "We should never have a null sub instance."); workItem = null; var lookupScope = scope; if (scope.IsDefault) { lookupScope = this.defaultScope; } // We don't really care about the return value since we'll // use null to know we should check uninitialized sub instances this.bookmarkManagers.TryGetValue(lookupScope, out var manager); if (manager == null) { Fx.Assert(lookupScope != null, "The sub instance should not be default if we are here."); var finalResult = BookmarkResumptionResult.NotFound; // Check the uninitialized sub instances for a matching bookmark if (this.uninitializedScopes != null) { for (var i = 0; i < this.uninitializedScopes.Count; i++) { var uninitializedScope = this.uninitializedScopes[i]; Fx.Assert(this.bookmarkManagers.ContainsKey(uninitializedScope), "We must always have the uninitialized sub instances."); BookmarkResumptionResult resumptionResult; if (!this.bookmarkManagers[uninitializedScope].TryGetBookmarkFromInternalList(bookmark, out var internalBookmark, out var callbackWrapper)) { resumptionResult = BookmarkResumptionResult.NotFound; } else if (IsExclusiveScopeUnstable(internalBookmark)) { resumptionResult = BookmarkResumptionResult.NotReady; } else { resumptionResult = this.bookmarkManagers[uninitializedScope].TryGenerateWorkItem(executor, true, ref bookmark, value, isolationInstance, out workItem); } if (resumptionResult == BookmarkResumptionResult.Success) { // We are using InitializeBookmarkScopeWithoutKeyAssociation because we know this is a new uninitialized scope and // the key we would associate is already associated. And if we did the association here, the subsequent call to // FlushBookmarkScopeKeys would try to flush it out, but it won't have the transaction correct so will hang waiting for // the transaction that has the PersistenceContext locked to complete. But it won't complete successfully until // we finish processing here. InitializeBookmarkScopeWithoutKeyAssociation(uninitializedScope, scope.Id); // We've found what we were looking for return(BookmarkResumptionResult.Success); } else if (resumptionResult == BookmarkResumptionResult.NotReady) { // This uninitialized sub-instance has a matching bookmark but // it can't currently be resumed. We won't return BookmarkNotFound // because of this. finalResult = BookmarkResumptionResult.NotReady; } else { if (finalResult == BookmarkResumptionResult.NotFound) { // If we still are planning on returning failure then // we'll incur the cost of seeing if this scope is // stable or not. if (!IsStable(uninitializedScope, nonScopedBookmarksExist)) { // There exists an uninitialized scope which is unstable. // At the very least this means we'll return NotReady since // this uninitialized scope might eventually contain this // bookmark. finalResult = BookmarkResumptionResult.NotReady; } } } } }
public BookmarkResumptionResult TryGenerateWorkItem(ActivityExecutor executor, bool isExternal, ref Bookmark bookmark, object value, System.Activities.ActivityInstance isolationInstance, out ActivityExecutionWorkItem workItem) { Bookmark internalBookmark = null; BookmarkCallbackWrapper callbackWrapper = null; if (!this.TryGetBookmarkFromInternalList(bookmark, out internalBookmark, out callbackWrapper)) { workItem = null; return BookmarkResumptionResult.NotFound; } bookmark = internalBookmark; if (!ActivityUtilities.IsInScope(callbackWrapper.ActivityInstance, isolationInstance)) { workItem = null; return BookmarkResumptionResult.NotReady; } workItem = callbackWrapper.CreateWorkItem(executor, isExternal, bookmark, value); if (!BookmarkOptionsHelper.SupportsMultipleResumes(callbackWrapper.Options)) { this.Remove(bookmark, callbackWrapper); } return BookmarkResumptionResult.Success; }
public BookmarkResumptionResult TryGenerateWorkItem(ActivityExecutor executor, bool isExternal, ref Bookmark bookmark, object value, ActivityInstance isolationInstance, out ActivityExecutionWorkItem workItem) { Bookmark internalBookmark = null; BookmarkCallbackWrapper callbackWrapper = null; if (!this.TryGetBookmarkFromInternalList(bookmark, out internalBookmark, out callbackWrapper)) { workItem = null; return(BookmarkResumptionResult.NotFound); } bookmark = internalBookmark; if (!ActivityUtilities.IsInScope(callbackWrapper.ActivityInstance, isolationInstance)) { workItem = null; // We know about the bookmark, but we can't resume it yet return(BookmarkResumptionResult.NotReady); } workItem = callbackWrapper.CreateWorkItem(executor, isExternal, bookmark, value); if (!BookmarkOptionsHelper.SupportsMultipleResumes(callbackWrapper.Options)) { // cleanup bookmark on resumption unless the user opts into multi-resume Remove(bookmark, callbackWrapper); } return(BookmarkResumptionResult.Success); }
public BookmarkResumptionResult TryGenerateWorkItem(ActivityExecutor executor, bool isExternal, ref Bookmark bookmark, object value, System.Activities.ActivityInstance isolationInstance, out ActivityExecutionWorkItem workItem) { Bookmark internalBookmark = null; BookmarkCallbackWrapper callbackWrapper = null; if (!this.TryGetBookmarkFromInternalList(bookmark, out internalBookmark, out callbackWrapper)) { workItem = null; return(BookmarkResumptionResult.NotFound); } bookmark = internalBookmark; if (!ActivityUtilities.IsInScope(callbackWrapper.ActivityInstance, isolationInstance)) { workItem = null; return(BookmarkResumptionResult.NotReady); } workItem = callbackWrapper.CreateWorkItem(executor, isExternal, bookmark, value); if (!BookmarkOptionsHelper.SupportsMultipleResumes(callbackWrapper.Options)) { this.Remove(bookmark, callbackWrapper); } return(BookmarkResumptionResult.Success); }
public BookmarkResumptionResult TryGenerateWorkItem(ActivityExecutor executor, ref Bookmark bookmark, BookmarkScope scope, object value, System.Activities.ActivityInstance isolationInstance, bool nonScopedBookmarksExist, out ActivityExecutionWorkItem workItem) { BookmarkManager manager = null; Bookmark bookmark3; BookmarkCallbackWrapper wrapper2; BookmarkResumptionResult result3; workItem = null; BookmarkScope key = scope; if (scope.IsDefault) { key = this.defaultScope; } this.bookmarkManagers.TryGetValue(key, out manager); if (manager == null) { BookmarkResumptionResult notFound = BookmarkResumptionResult.NotFound; if (this.uninitializedScopes != null) { for (int i = 0; i < this.uninitializedScopes.Count; i++) { Bookmark bookmark2; BookmarkCallbackWrapper wrapper; BookmarkResumptionResult notReady; BookmarkScope scope3 = this.uninitializedScopes[i]; if (!this.bookmarkManagers[scope3].TryGetBookmarkFromInternalList(bookmark, out bookmark2, out wrapper)) { notReady = BookmarkResumptionResult.NotFound; } else if (this.IsExclusiveScopeUnstable(bookmark2)) { notReady = BookmarkResumptionResult.NotReady; } else { notReady = this.bookmarkManagers[scope3].TryGenerateWorkItem(executor, true, ref bookmark, value, isolationInstance, out workItem); } switch (notReady) { case BookmarkResumptionResult.Success: this.InitializeBookmarkScopeWithoutKeyAssociation(scope3, scope.Id); return(BookmarkResumptionResult.Success); case BookmarkResumptionResult.NotReady: notFound = BookmarkResumptionResult.NotReady; break; default: if ((notFound == BookmarkResumptionResult.NotFound) && !this.IsStable(scope3, nonScopedBookmarksExist)) { notFound = BookmarkResumptionResult.NotReady; } break; } } } return(notFound); } if (!manager.TryGetBookmarkFromInternalList(bookmark, out bookmark3, out wrapper2)) { result3 = BookmarkResumptionResult.NotFound; } else if (this.IsExclusiveScopeUnstable(bookmark3)) { result3 = BookmarkResumptionResult.NotReady; } else { result3 = manager.TryGenerateWorkItem(executor, true, ref bookmark, value, isolationInstance, out workItem); } if ((result3 == BookmarkResumptionResult.NotFound) && !this.IsStable(key, nonScopedBookmarksExist)) { result3 = BookmarkResumptionResult.NotReady; } return(result3); }