/// <summary> /// Synchronizes the specified matrix. /// </summary> /// <param name="matrix">The matrix.</param> /// <returns></returns> public bool Synchronize(bool[,] matrix) { bool success = true; if (ActiveAdapter != null) { System.Threading.Tasks.Task T = new System.Threading.Tasks.Task(() => { ActiveAdapter.Synchronize(matrix); }); T.Start(); } if (Adapters.Count > 0) { if (Adapters.Count > 1) { System.Threading.Tasks.Parallel.ForEach <IBrailleIOAdapter>(Adapters, (item) => { try { if (item != null && item != ActiveAdapter && item is AbstractBrailleIOAdapterBase && ((AbstractBrailleIOAdapterBase)item).Synch) { item.Synchronize(matrix); } } catch { success = false; } }); } else if (ActiveAdapter == null) { System.Threading.Tasks.Task T2 = new System.Threading.Tasks.Task(() => { try { IBrailleIOAdapter item = null; item = Adapters.ElementAt(0); if (item != null && item != ActiveAdapter && item is AbstractBrailleIOAdapterBase && ((AbstractBrailleIOAdapterBase)item).Synch) { item.Synchronize(matrix); } } catch { success = false; } }); T2.Start(); } } return(success); }
/// <summary> /// Synchronizes the specified matrix. /// </summary> /// <param name="matrix">The matrix.</param> /// <returns></returns> public bool Synchronize(bool[,] matrix) { bool success = true; ActiveAdapter.Synchronize(matrix); foreach (var item in Adapters) { try { if (item != null && item != ActiveAdapter && item is AbstractBrailleIOAdapterBase && ((AbstractBrailleIOAdapterBase)item).Synch) { item.Synchronize(matrix); } } catch { success = false; } } return(success); }