private void ExecuteInternal(Binding[] bindings) { foreach (var binding in bindings) { if (!binding.IsScheduled) { _scheduledBindings.Enqueue(new ScheduledBinding(binding, _executingBinding)); binding.IsScheduled = true; _tracer?.Invoke(string.Format("Scheduled binding {0}", binding.DebugContext.Description)); } else { _tracer?.Invoke(string.Format("Ignored binding {0}", binding.DebugContext.Description)); } } if (_executingBinding == null) { try { while (_scheduledBindings.Count > 0) { _executingBinding = _scheduledBindings.Dequeue(); _executingBinding.Binding.IsScheduled = false; _tracer?.Invoke(string.Format("Executing binding {0}", _executingBinding.Binding.DebugContext.Description)); if (Binder.DebugMode) { ExecuteWithVirtualStack(); } else { _executingBinding.Binding.Execute(); } } } catch (Exception) { foreach (var tp in _scheduledBindings) { tp.Binding.IsScheduled = false; } _scheduledBindings.Clear(); throw; } finally { _executingBinding = null; } } }
public ScheduledBinding(Binding binding, ScheduledBinding parent) { Binding = binding; Parent = parent; }