private async Task RunStep(IRotation rotation, int solutionCount) { WriteLine("Executing step {0}/{1}: {2}", ++m_currentStep, solutionCount, rotation); var cubeRotation = rotation as CubeRotation; var faceRotation = rotation as FaceRotation; var tasks = new List<Task>(); if (cubeRotation != null) { tasks.Add(m_configuration.RotateCube(cubeRotation)); if (m_display != null) tasks.Add(m_display.RotateCube(cubeRotation)); } if (faceRotation != null) { tasks.Add(m_configuration.Rotate(faceRotation)); if (m_display != null) tasks.Add(m_display.Rotate(faceRotation)); } await Task.WhenAll(tasks).ConfigureAwait(true); }
public static async Task ApplyAndAddRotation(IRotation rotation, ICollection<IRotation> rotations, IRotatable configuration) { if (rotation == null) return; rotations.Add(rotation); var cubeRotation = rotation as CubeRotation; var faceRotation = rotation as FaceRotation; if (cubeRotation != null) { await configuration.RotateCube(cubeRotation).ConfigureAwait(false); } if (faceRotation != null) { await configuration.Rotate(faceRotation).ConfigureAwait(false); } }
private Task StartRotating(IRotation rotation) { m_rotationTask = new TaskCompletionSource<object>(); m_timesRun = 0; m_currentRotation = rotation; SetNextRotation(); return m_rotationTask.Task; }