public void OnTimerTick(object sender, EventArgs eventArgs) { lock (_lock) { var status = NetworkStatus.Values.All(x => x); var zeroStatus = NetworkStatus[0]; if (status && Package.Count > 0) { var newPackage = new InputEventArgs(0, Package); Console.WriteLine( $"{id++} Sent from #{255} to #{newPackage.Address} -> Package X:{Package.First()} Y: {Package.Last()}"); PackageInReady?.Invoke(null, newPackage); if (PreviousPackage.Count > 0 && PreviousPackage.Last() == Package.Last()) { Console.WriteLine( $"Previous id{previousId} Y #{PreviousPackage.Last()} -> id{id - 1} Package Y: {Package.Last()}"); } PreviousPackage = Package; previousId = id - 1; } } }
public void HandleNewPackage(object sender, OutputEventArgs e) { lock (_lock) { var address = e.Address; var package = e.OutputPackage; var newPackage = new InputEventArgs(address, package); Console.WriteLine($"{id++} Sent from #{e.From} to #{address} -> Package X:{package.First()} Y: {package.Last()}"); if (address != 255) { PackageInReady?.Invoke(null, newPackage); } else { Package = package; //newPackage = new InputEventArgs(0, Package); //Console.WriteLine($"Sent from #{255} to #{address} -> Package X:{Package.First()} Y: {Package.Last()}"); //PackageInReady?.Invoke(null, newPackage); ////PackageInReady?.Invoke(null, newPackage); } } }