#include "stdafx.h"
#include "yuniminWindows.h"

bool initialization()
{
	setConnection();
	return startClient();
}

void run();

void finish()
{
	endClient();
}

DWORD WINAPI singleRobot(LPVOID lpParam)
{
	if( !initialization() )
	{
		return 0;
	}
	std::cout << "Program is running..." << std::endl;
	run();
	std::cout << "Program finished..." << std::endl;
	finish();
	return 0;
}

int main(int argc, char * argv[])
{
	const int pocetRobotu = 1;

	DWORD dwThreadId;
	LPVOID argument = 0;
	HANDLE vlakna[pocetRobotu];
	for(int i=0;i<pocetRobotu;i++)
	{
		vlakna[i] = CreateThread(NULL,0,singleRobot,argument,0,&dwThreadId);
	}
	for(int i=0;i<pocetRobotu;i++)
	{
		WaitForSingleObject(vlakna[i],INFINITE);
	}
	return 0;
}