/// <summary> /// Sending false signal to all finish nodes. This causes all nodes, that haven't work yet to be uncallable, and all working nodes to stop. /// So, the graph finishes with false signals. /// </summary> public void UndoAsync() { lock (StopingLock) { if (WasStoped) { return; } StopingEvent.WaitOne(); StopingEvent.Reset(); } System.Diagnostics.Debug.WriteLine("Undo"); PrepareFlow(); First.ClearFilters(); foreach (var firstNode in First) { firstNode.OnNotifyBack += OnFirstFinished; } foreach (var last in Last) { IColorable last1 = last; new Thread(() => last1.NotifyBack(last1, new UndoSignal())) { IsBackground = true }.Start(); } }
/// <summary> /// Sends null to all first points - all nodes reset their clear state. /// </summary> public void ClearGraphAsync() { Stop(); lock (ClearingLock) { if (WasCleared) { return; } //if working when wait for work to finish ClearingEvent.WaitOne(); StopingEvent.WaitOne(); //TODO f**k //StartedEvent.WaitOne(); //Start working (sending null ClearingEvent.Reset(); } System.Diagnostics.Debug.WriteLine("Clearing"); PrepareFlow(); Last.ClearFilters(); foreach (var lastNode in Last) { lastNode.OnFlow += OnLastFlow; } foreach (var first in First) { IColorable first1 = first; new Thread(() => first1.Flow(first1, null)) { IsBackground = true }.Start(); } }
protected override void Clear() { lock (this) { base.Clear(); Input.ClearFilters(); } }
protected override void Clear() { lock (this) { base.Clear(); Connections.ClearFilters(); } }
public void StartAsync() { //enter only one thread lock (StartingLock) { //if working when wait for work to finish StartedEvent.WaitOne(); //Start working StartedEvent.Reset(); } GetStartColors(); if (NodesToNotify.FilteredCount == NodesToNotify.Count) { if (NodesToNotify.Count == 0) { Finish(); } return; } Stop(); ClearGraph(); System.Diagnostics.Debug.WriteLine("Starting"); WasCleared = false; WasStoped = false; PrepareFlow(); NodesToNotify.ClearFilters(); foreach (var notifyNode in NodesToNotify) { notifyNode.OnNotifyBack += OnNotifyNodeFinished; } //Set onNotifyBackEvent for all nodes if (OnGlobalError != null) { Traverse(First, current => current.GetNextPaths(), current => { var colorableClass = current as ColorableClass; if (colorableClass != null) { colorableClass.OnNotifyBack += InvokeGlobalError; } }, null); } foreach (var first in First) { IColorable first1 = first; Color color; if (StartColors.ContainsKey(first)) { color = StartColors[first]; } else { color = null; } new Thread(() => first1.Flow(first1, color)) { IsBackground = true }.Start(); } }