static void Main(string[] args) { server server = new server(); HandleDataClass hdc = new HandleDataClass(); //start server thread Thread serverThread = new Thread(() => server.Listen()); serverThread.Start(); //start Handler thread Thread dataHandlerThread = new Thread(() => hdc.SubscribeToEvent(server)); dataHandlerThread.Start(); //Do other things while (true) { Thread.Sleep(100); } }
public void SubscribeToEvent(server server) { server.DataReceivedEvent += Server_DataReceivedEvent; }