public static void SelectEntity(IEnumerable <Entity> entities) { // Update property editor selection. if (selectedEntitiesContext != null) { selectedEntitiesContext.ViewModelByGuid.Clear(); var viewModels = entities .Where(entity => entity != null) .Select(entity => selectedEntitiesContext.GetModelView(entity).Children.First(x => x.PropertyName == "Components")) .ToArray(); if (viewModels.Count() > 1) { selectedEntitiesContext.Root = ViewModelController.Combine(selectedEntitiesContext, viewModels); } else { selectedEntitiesContext.Root = viewModels.FirstOrDefault(); } } // Update picking system (gizmo). // It will also update the remote selection in entity tree view. var entitiesArray = entities.ToArray(); if (!ArrayExtensions.ArraysEqual(pickingSystem.SelectedEntities, entitiesArray)) { pickingSystem.SelectedEntities = entitiesArray; } entitiesChangePacketEvent.Set(); }
private IEnumerator <IAsyncResult> ExecuteImpl <T>(AsyncProcessor.WorkItem <T> workItem, TimeSpan timeout, AsyncIteratorContext <T> context) { object obj = null; object obj1 = null; Duration startingNow = Duration.StartingNow; if (timeout == TimeSpan.Zero) { throw new TimeoutException("Timed out in AsyncSemaphore"); } if (timeout < TimeSpan.Zero) { throw new ArgumentOutOfRangeException("timeout", (object)timeout, "Must be >= 0"); } bool flag = false; try { object obj2 = this.syncObj; object obj3 = obj2; obj = obj2; Monitor.Enter(obj3, ref flag); if (this.state != AsyncProcessor.State.Running) { throw new InvalidOperationException("AsyncProcessor must be running first"); } } finally { if (flag) { Monitor.Exit(obj); } } IAsyncResult asyncResult = this.asyncSemaphore.BeginAcquire(timeout, context.GetResumeCallback(), context.GetResumeState("AsyncProcessor.ExecuteImpl")); yield return(asyncResult); this.asyncSemaphore.EndAcquire(asyncResult); using (AsyncSignal <T> asyncSignal = new AsyncSignal <T>()) { asyncResult = asyncSignal.BeginWait(startingNow.Remaining(timeout), context.GetResumeCallback(), context.GetResumeState("AsyncProcessor.ExecuteImpl")); Guid activityId = AsyncHelper.Trace.ActivityId; bool flag1 = false; try { object obj4 = this.syncObj; object obj5 = obj4; obj1 = obj4; Monitor.Enter(obj5, ref flag1); Queue <AsyncProcessor.WorkItemJob> workItemJobs = this.workItemQueue; workItemJobs.Enqueue(new AsyncProcessor.WorkItemJob(() => { Exception exception = null; T cSu0024u003cu003e8_localsa = default(T); try { AsyncHelper.Trace.ActivityId = activityId; cSu0024u003cu003e8_localsa = workItem(startingNow.Remaining(timeout)); } catch (Exception exception1) { exception = exception1; } if (exception != null) { asyncSignal.Abort(exception); } else { asyncSignal.Set(cSu0024u003cu003e8_localsa); } this.asyncSemaphore.Release(1); })); } finally { if (flag1) { Monitor.Exit(obj1); } } this.semaphore.Release(); yield return(asyncResult); context.ResultData = asyncSignal.EndWait(asyncResult); } }