/// <summary> /// Receives requests from the client and sends them to the TaskHandler, /// so that the requested task is carried out. /// </summary> /// <param name="State">this parameter is not used in the function. /// The Thread class, which calls this function, requires this parameter</param> public void handle(Object State) { while (true) { try { byte[] data = new byte[1024]; int recv = client.Receive(data); if (recv == 0) { break; } string str = Encoding.ASCII.GetString( data, 0, recv); p.DoNewTask(str, tHandler); } catch { break; } } client.Close(); }
public void handle(Object State) { //IPresenter presenter = (IPresenter)ThreadContext; while (true) { byte[] data = new byte[1024]; int recv = client.Receive(data); if (recv == 0) { break; } string str = Encoding.ASCII.GetString( data, 0, recv); p.DoNewTask(str, tHandler); //Console.WriteLine (str); Console.WriteLine("continues in parallel"); //data = Encoding.ASCII.GetBytes (str); //client.Send (data, recv, SocketFlags.None); } Console.WriteLine("left while"); client.Close(); }