Cleanest way to exit processes?

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

User avatar
stegemma
Posts: 859
Joined: Mon Aug 10, 2009 10:05 pm
Location: Italy
Full name: Stefano Gemma

Re: Cleanest way to exit processes?

Post by stegemma »

A best alternative to wait for processes to terminates could be this one:

Code: Select all

clsTourney::~clsTourney()
{
	for &#40;int i = 0; i < cllEngines.Count&#40;); i++)
	&#123;
		cllEngines&#91;i&#93;->PushCommand&#40;"quit");
	&#125;
	Sleep_ms&#40;2000&#41;;
	cllEngines.Clear&#40;);
&#125;
I've moved the engines handling from the wxWidgets derived component to an external "neutral" object (that I could use without the graphical interface) and then the sleep function has been moved outside the loop, so that I can wait 2 seconds or more, instead of one second for any engine loaded. The "quit" command will be executed by any engine thread concurrently, virtually using the same wait interval.
Author of Drago, Raffaela, Freccia, Satana, Sabrina.
http://www.linformatica.com