//TODO: Use log to instead temporarily, //need to decide whether to show these failures on error window public void HandleException(Exception exception) { //await Dispatcher.CurrentDispatcher.InvokeAsync(() => //{ // ExceptionDispatchInfo.Capture(exception).Throw(); //}, DispatcherPriority.Send).Task.ConfigureAwait(false); RNTracer.Error(ReactConstants.Tag, "[RN_EXCEPTION] DisabledDevSupportManager::HandleException:[" + exception.ToString() + "]"); EcoreLoopProxy.Quit(); }
/// <summary> /// Dispatches the view updates. /// </summary> /// <param name="batchId">The batch identifier.</param> internal void DispatchViewUpdates(int batchId) { var operations = _operations.Count == 0 ? null : _operations; if (operations != null) { _operations = new List <Action>(); } var nonBatchedOperations = default(Action[]); lock (_nonBatchedGate) { if (_nonBatchedOperations.Count > 0) { nonBatchedOperations = _nonBatchedOperations.ToArray(); _nonBatchedOperations.Clear(); } else { nonBatchedOperations = null; } } lock (_gate) { _batches.Add(() => { using (RNTracer.Trace(RNTracer.TRACE_TAG_REACT_BRIDGE, "DispatchUI") .With("BatchId", batchId) .Start()) { if (nonBatchedOperations != null) { foreach (var operation in nonBatchedOperations) { operation(); } } if (operations != null) { foreach (var operation in operations) { operation(); } } _nativeViewHierarchyManager.ClearLayoutAnimation(); } }); } //Runing batches async EcoreLoopProxy.PostAndWakeUp(FlushPendingBatches); }
public DispatcherMessageQueueThread(string name, Action <Exception> handler) : base(name) { _actionSubject = new Subject <Action>(); _actionObserver = _actionSubject; _subscription = _actionSubject //Remove "ObserveOn" //TODO: Need to check whether it can works well. //.ObserveOn(Dispatcher.CurrentDispatcher) .Subscribe(action => { try { //Sync call EcoreLoopProxy.Send(action); } catch (Exception ex) { RNTracer.Error(ReactConstants.Tag, "[RN_EXCEPTION]At action:[" + ex.ToString() + "]"); handler(ex); } }); }
public static void RunOnDispatcher(Action action) { //Async call EcoreLoopProxy.PostAndWakeUp(action); //await new Task(action); // TODO: bind to the ecore main loop }