/// <summary> /// Constructor. Protected to avoid unwitting usage - AsyncOperation objects /// are typically created by AsyncOperationManager calling CreateOperation. /// </summary> private AsyncOperation(object userSuppliedState, SynchronizationContext syncContext) { _userSuppliedState = userSuppliedState; _syncContext = syncContext; _alreadyCompleted = false; _syncContext.OperationStarted(); }
internal AsyncOperation (SynchronizationContext ctx, object state) { this.ctx = ctx; this.state = state; ctx.OperationStarted (); }
internal AsyncOperation(SynchronizationContext synchronizationContext, object userSuppliedState) { _synchronizationContext = synchronizationContext; _userSuppliedState = userSuppliedState; _synchronizationContext.OperationStarted(); }
public static void Post(SynchronizationContext synchronizationContext, SendOrPostCallback callback, object state) { Fx.Assert(synchronizationContext != null, "Null Sync Context"); Fx.Assert(callback != null, "Null Callback"); synchronizationContext.OperationStarted(); synchronizationContext.Post(wrapperCallback, new PostCallbackState(synchronizationContext, callback, state)); }
/// <summary> /// Updates the destination fields. /// </summary> /// <param name="storedFields">The stored fields.</param> /// <param name="destinationFields">The destination fields.</param> /// <param name="syncContext">The synchronize context.</param> private static void UpdateDestinationFields(IList<IExpressionField> storedFields, IEnumerable<IExpressionField> destinationFields, SynchronizationContext syncContext) { var newDestinationFields = destinationFields.ToArray(); foreach (var field in newDestinationFields) { var exField = (from f in storedFields where ((DestinationField)f).SystemName == ((DestinationField)field).SystemName select f).FirstOrDefault(); if (exField == null) { storedFields.Add(field); } else { //ensure that old script is updated var exf = (DestinationField)exField; var df = (DestinationField)field; exf.SetName = df.SetName; exf.Name = df.Name; exf.InnerName = df.InnerName; exf.SystemName = df.SystemName; exf.DataType = df.DataType; exf.SubfieldsRetriever = df.SubfieldsRetriever; exf.IsKeyVisible = df.IsKeyVisible; exf.IsKeyEnabled = df.IsKeyEnabled; exf.IsKey = exf.IsKey && df.IsKeyEnabled; exf.IsRequired = df.IsRequired; exf.ConnectorIn.Name = df.ConnectorIn.Name; exf.ConnectorIn.DataType = df.ConnectorIn.DataType; exf.ConnectorIn.Validator = df.ConnectorIn.Validator != null ? df.ConnectorIn.Validator.Clone(exf.ConnectorIn) : null; exf.ConnectorIn.IsNullable = df.ConnectorIn.IsNullable; if (exField.Subfields.Count > 0 && field.SubfieldsRetriever != null) { syncContext.OperationStarted(); field.SubfieldsRetriever.BeginLoad( exField, (f, l) => { UpdateDestinationFields(exField.Subfields, l, syncContext); syncContext.OperationCompleted(); }); } else { UpdateDestinationFields(exField.Subfields, field.Subfields, syncContext); } } } for (var i = storedFields.Count - 1; i >= 0; --i) { var newField = (from f in newDestinationFields where ((DestinationField)f).SystemName == ((DestinationField)storedFields[i]).SystemName select f) .FirstOrDefault(); if (newField == null) { storedFields.RemoveAt(i); } } }