954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Threads and sleep

how can I sleep my program without sleeping others (or making them slower)?
I am using a windows application. here is a fragment of my code:

//#includes...
int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, char * cmdParam, int cmdShow)
{
	MSG  msg;
	int status;
	Window myWind(SW_SHOW,"Name",150,120,500,0);
	for(int i=0;i<550;i++){
		myWind.setLocation(i,i);
		//here is my problem
		//is there another way (like a thread)?
		Sleep(100);
	}
	while ((status = GetMessage (& msg, 0, 0, 0)) != 0)
	{
		if (status == -1)
		{
			return -1;
		}
		DispatchMessage (& msg);
	}
	return msg.wParam;
}
teo236
Junior Poster in Training
73 posts since Jul 2011
Reputation Points: 20
Solved Threads: 10
 

>>how can I sleep my program without sleeping others (or making them slower)?

You can't make other programs sleep... What are you talking about, what are "the others". The Sleep function is perfectly ok, it "Suspends the execution of the current thread until the time-out interval elapses." - msdn. What else do you want? If your other threads are seem to go to sleep, then it's a problem with those threads, not with the use of Sleep().

mike_2000_17
Posting Virtuoso
Moderator
2,139 posts since Jul 2010
Reputation Points: 1,634
Solved Threads: 457
 

im using windows 7 and every time I run my program every program gets slower than normal(very). if I click another window while my program is running my program stops responding.

teo236
Junior Poster in Training
73 posts since Jul 2011
Reputation Points: 20
Solved Threads: 10
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: