Buttons not showing up!

Pages: 12
The only condition under which both threads would attempt to modify the variable at the same time is if the user managed two inputs in the space of these lines:
1
2
3
4
5
6
7
	while(stay)
	{
        srand(time(NULL));
		bool ** grid;
		HWND ** buttons;
		int sizes[4];
		stay = 2;

Really, for the purposes of a game only 10 or so people are ever going to play, I don't think it's ever going to happen.
No offense, but that's the same kind of reasoning that "I should just make all my variables global because I am the only one looking at it." It's a stupid statement to make because it gets you into bad habits, and what if someone who wants to employ you wishes to see that program?
The only condition under which both threads would attempt to modify the variable at the same time is if the user managed two inputs in the space of these lines:


Correction. It can happen if your threads process the input concurrently. Not if it's entered concurrently. A thread could be paused, or sleeped by the CPU scheduler just long enough to cause a conflict.

But hey, you don't have to take my advice.
I didn't say concurrently. The loop only loops after an input.

Firedraco, you have a point, but I tend to target my programs at the sort of people who might be using them. I don't foolproof programs not intended for fools, and I don't go out of my way to add code to account for 1/1000000 chances of failure when the program will only be run 100 times.
IMO. Your thread is a hack way to stop the application.

Because your not using an OOD philosophy your best bet is to have a global boolean that is something like bool bContinue = true; that gets flagged to false in the Window Callback function (WinProc) and is checked within the message loop.
I have heard it said: "Never trust the user."

While assuming good input is fine for a basic game that probably will not be released for sale, such a practice will likely prevent you from becoming a professional programmer.

The idea is that you should foolproof programs and go out of your way to check for any possible error. Like Zaita said: if you are not going to use OOD, you should just make a global boolean value that is set, and the threads check that to determine whether they can access the variables.
My thread exists to accept input without having to pause the program. It is 100% impossible to have the threads access the variable at the same time, because the thread gets DESTROYED before the main program accesses the variable. Nonstandard doesn't always mean nonfunctioning. It's fine. A boolean doesn't help in the least.
Last edited on
How can you presume to know this? The thread could be temporarily sleeped, while the main thread continued, then they could both access stay. You have no guarantee the main thread will not be accessing stay until the other threads have terminated.

But like Zaita said, you do not have to listen to what we have to say. Just do not expect a programming like that to fly professionally.
Nonstandard doesn't always mean nonfunctioning.


Yes, but functioning doesn't always mean standard.
Correct.
Topic archived. No new replies allowed.
Pages: 12