private static void Client_OnEvent(DistClient sender, DistEvent e) { // Check if message is from us if (e.GetSource() == sender.GetClientID().InstanceID) { return; } if (counter == 0) { recv_timer = new Timer(); } if (e.GetAttributeValue("Cnt") != counter) { Console.WriteLine("Error"); } counter++; if (counter == COUNT) { Console.WriteLine($"Received {COUNT} events in {recv_timer.GetTime()} seconds -> Frequency: {recv_timer.GetFrequency(COUNT)} "); counter = 0; } }
static public void RestorePropertiesAndFields(DistEvent e, object obj, bool allProperties = false) { foreach (System.Reflection.PropertyInfo prop in obj.GetType().GetProperties()) { if (allProperties || Attribute.IsDefined(prop, typeof(DistProperty))) { prop.SetValue(obj, e.GetAttributeValue(prop.Name).GetObject(prop.PropertyType, allProperties)); } } foreach (System.Reflection.FieldInfo field in obj.GetType().GetFields()) { if (allProperties || Attribute.IsDefined(field, typeof(DistProperty))) { field.SetValue(obj, e.GetAttributeValue(field.Name).GetObject(field.FieldType, allProperties)); } } }
private static void Client_OnEvent(DistClient sender, DistEvent e) { if (counter == 0) { recv_timer = new Timer(); } if (e.GetAttributeValue("Cnt") != counter) { Console.WriteLine("Error"); } counter++; if (counter == COUNT) { Console.WriteLine($"Received {COUNT} events in {recv_timer.GetTime()} seconds -> Frequency: {recv_timer.GetFrequency(COUNT)} "); counter = 0; } }