/// <summary> /// Called by <see cref="DataPortal" /> to update a /// business object. /// </summary> /// <param name="obj">The business object to update.</param> /// <param name="context"> /// <see cref="Server.DataPortalContext" /> object passed to the server. /// </param> /// <param name="isSync">True if the client-side proxy should synchronously invoke the server.</param> public async Task <DataPortalResult> Update(object obj, DataPortalContext context, bool isSync) { if (isSync || Csla.ApplicationContext.LogicalExecutionLocation == ApplicationContext.LogicalExecutionLocations.Server) { return(await _portal.Update(obj, context, isSync)); } else { var tcs = new TaskCompletionSource <DataPortalResult>(); var bw = new Csla.Threading.BackgroundWorker(); bw.DoWork += (s, o) => { o.Result = _portal.Update(obj, context, isSync).Result; }; bw.RunWorkerCompleted += (s, o) => { if (o.Error == null) { tcs.TrySetResult((DataPortalResult)o.Result); } else { tcs.TrySetException(o.Error); } }; bw.RunWorkerAsync(); return(await tcs.Task); } }
/// <summary> /// Called by <see cref="DataPortal" /> to update a /// business object. /// </summary> /// <param name="obj">The business object to update.</param> /// <param name="context"> /// <see cref="Server.DataPortalContext" /> object passed to the server. /// </param> /// <param name="isSync">True if the client-side proxy should synchronously invoke the server.</param> public async Task <DataPortalResult> Update(object obj, DataPortalContext context, bool isSync) { DataPortalResult result; SetApplicationContext(obj, CurrentApplicationContext); if (isSync || OriginalApplicationContext.LogicalExecutionLocation == ApplicationContext.LogicalExecutionLocations.Server) { result = await _portal.Update(obj, context, isSync); } else { if (!Options.FlowSynchronizationContext || SynchronizationContext.Current == null) { result = await Task.Run(() => this._portal.Update(obj, context, isSync)); } else { result = await await Task.Factory.StartNew(() => this._portal.Update(obj, context, isSync), CancellationToken.None, TaskCreationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); } } SetApplicationContext(result.ReturnObject, OriginalApplicationContext); SetApplicationContext(result.Error, OriginalApplicationContext); return(result); }
/// <summary> /// Called by <see cref="DataPortal" /> to update a /// business object. /// </summary> /// <param name="obj">The business object to update.</param> /// <param name="context"> /// <see cref="Server.DataPortalContext" /> object passed to the server. /// </param> /// <param name="isSync">True if the client-side proxy should synchronously invoke the server.</param> public async Task <DataPortalResult> Update(object obj, DataPortalContext context, bool isSync) { if (isSync || Csla.ApplicationContext.LogicalExecutionLocation == ApplicationContext.LogicalExecutionLocations.Server) { return(await _portal.Update(obj, context, isSync)); } else { return(await await _taskFactory.StartNew(() => this._portal.Update(obj, context, isSync))); } }
/// <summary> /// Called by <see cref="DataPortal" /> to update a /// business object. /// </summary> /// <param name="obj">The business object to update.</param> /// <param name="context"> /// <see cref="Server.DataPortalContext" /> object passed to the server. /// </param> /// <param name="isSync">True if the client-side proxy should synchronously invoke the server.</param> public async Task <DataPortalResult> Update(object obj, DataPortalContext context, bool isSync) { if (isSync || Csla.ApplicationContext.LogicalExecutionLocation == ApplicationContext.LogicalExecutionLocations.Server) { return(await _portal.Update(obj, context, isSync)); } else { if (SynchronizationContext.Current == null) { return(await await this._taskFactory.StartNew(() => this._portal.Update(obj, context, isSync))); } return(await await this._taskFactory.StartNew(() => this._portal.Update(obj, context, isSync), CancellationToken.None, TaskCreationOptions.None, TaskScheduler.FromCurrentSynchronizationContext())); } }
public DataPortalResult Update(object obj, DataPortalContext context) { return(_portal.Update(obj, context)); }
public Server.DataPortalResult Update(object obj, Server.DataPortalContext context) { return(Portal.Update(obj, context)); }