public async Task DoC(string name) { Console.WriteLine($"{name} created"); // calculate accessScope long accessScope = 3; using (IAccessContext <long> q = Context.CreateChild(accessScope)) { char contextName = NewContextName(); await q.UntilAvailable(); await Task.Run(() => { for (int i = 0; i < 5; i++) { work(q, name, contextName, "DoC"); } q.RequiredScope = 1; // perform something here for (int i = 0; i < 6; i++) { work(q, name, contextName, "DoC"); } }); } }
private async Task <long> readNextIndex( IAccessContext <enumeratorScope> subContext) { await subContext.UntilAvailable( new enumeratorScope(nextIndex : RWScope.Read)); return(nextIndex); }
private async Task setCurrentNode( node value, IAccessContext <enumeratorScope> subContext) { await subContext.UntilAvailable( new enumeratorScope(RWScope.ReadWrite)); currentNode = value; }
private async Task <node> readCurrentNode( IAccessContext <enumeratorScope> subContext) { await subContext.UntilAvailable( new enumeratorScope(RWScope.Read)); return(currentNode); }
/// <remarks> /// No child context of <paramref name="context"/> /// may be created und employed before /// the invocation of this method because /// this method itself does not create an own child context. /// </remarks> private async Task <node> getFirstNode(IAccessContext <CSScope> context) { await context.UntilAvailable(new CSScope( valueScope : InfiniteIntervalScope.Create( RWScope.Read, 0, 1))); return(state.FirstNode); }
private async Task incrementNextIndex( IAccessContext <enumeratorScope> subContext) { /* These two statemets (InChild and UntilAvailable) * could possibly be combined to a single * (extension) method for AccessContext. */ await subContext.InChild(new enumeratorScope( nextIndex : RWScope.ReadWrite), async c => { await subContext.UntilAvailable(); nextIndex++; }); }
/* Private methods may get the surrounding context to spare * the creation of a new Contextual instance. */ /// <remarks> /// No child context of <paramref name="context"/> /// may be created und employed before /// the invocation of this method because /// this method itself does not create an own child context. /// </remarks> private async Task <long> getCount(IAccessContext <CSScope> context) { await context.UntilAvailable(new CSScope(RWScope.Read)); return(state.Count); }