Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Program didn't exit in Task Manager after click [X]
Program didn't exit in Task Manager after click [X] [message #55268] Mon, 26 October 2020 02:36 Go to previous message
sinpeople is currently offline  sinpeople
Messages: 29
Registered: October 2020
Location: Singapore
Promising Member

Hi folks,

I have a dialog program which contains a "Start" button to start 2x thread services. It is copied and modified from an existing program. The original program does not have this program but this program has. I tried to isolate the program as the following:
1) Launch program, click [X] directly, program can exit
2) Launch program, click "Start" button, then click [X], program cannot exit.
I could not spot anything suspicious in the callback code of the button handling.
It is the following:

	btnStart <<= callback(this, &RegionalCtrl::SpawnTasks);



void RegionalCtrl::SpawnTasks()
{
	//Start Thread Remote Request; The Server Portion of the UDP TCP Service for Incoming Service
	//Request
	Thread udprpc;
	udprpc.Run(callback(this, &RegionalCtrl::UDPRpcServerThread));
	
	Thread tcprpc;
	tcprpc.Run(callback(this, &RegionalCtrl::TCPRpcServerThread)); 
	
	btnStart.Disable();
}

// Listenning here to figure any execution is needed
void RegionalCtrl::UDPRpcServerThread()
{
	UrrServer urr;
	urr.Create(m_nServerPort); 
	//Cout() << "URR Ping server\n";
	//while(false)
	for(;;) 
	{
		UrrRequest r;
		if(urr.Accept(r)) 
		{
			UdpRpcCmd(r);
		}
		Sleep(500);
	}
}

void RegionalCtrl::TCPRpcServerThread()
{
	TcpSocket server;
	if(!server.Listen(m_nServerPort+100, 5)) {
		Cout() << "Unable to initialize server socket!\n";
		SetExitCode(1);
		return;
	}
	Cout() << "Waiting for requests..\n";
	for(;;) 
	{
		TcpSocket s;
		if(s.Accept(server)) {
			String w = s.GetLine();
			TcpRpcCmd(w);
//			Cout() << "Request: " << w << " from: " << s.GetPeerAddr() << '\n';
			if(w == "time")
				s.Put(AsString(GetSysTime()));
			else
				s.Put(AsString(3 * atoi(~w)));
			s.Put("\n");
		}
		Sleep(500);
	}
}



I stepped into these 2 pieces of code. It didn't return back when the "if" statement is stepped into to get input strings. Comment either one of these 2 threads didn't help, unless comment both of them.

I have to kill the program every time when it is launched outside theIDE. It can exited properly if I launch it within theIDE for debug though. I checked back to the original program. These pieces of code are the same. Headache. Not sure what's the general advise to troubleshoot this kind of "Fail to exit completed from OS" problem.

Thank you very much!

Best Regards
David
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: report generator
Next Topic: Pie Chart in U++?
Goto Forum:
  


Current Time: Mon Apr 29 17:15:35 CEST 2024

Total time taken to generate the page: 0.03048 seconds