static void Main() { int port = 4000; string host = "127.0.0.1"; using (OutGauge outgauge = new OutGauge()) { outgauge.PacketReceived += new EventHandler <OutGaugeEventArgs>(myFunction); outgauge.Connect(host, port); Console.ReadKey(true); } }