Waitrud Weber’s blog

things and reminders for memories

3d: windows-make: What does the windows thread in C call.


On the windows thread. We carry on( ride on and execute ) the functions in C and in C++.
In C++, we usually use the class object like the following.

1. Set parameters.
2. Execute.
3. Get the result.
So, the program example is like the following.

1. Create_3D_Converter c3d = new Create_3D_Converter();
1-1. c3d.Set_Parameters( a, b, c );
2. c3d.Exececute();
3. Vectors all_points = (Vectors)c3d.GetResult();

However, windows-thread is just one called by windows-api basically.
And the thread is called every time by windows-api as every event in one function.
We are going to judge the event every by the switch-case and separate the code blocks like the below.

switch (*event) {

WM_KEYUP:
	break;
WM_PAINT:
	break;
}


If we put the C++ object on the above code,

switch (*event) {

WM_KEYUP:
	Create_3D_Converter c3d = new Create_3D_Converter();
	c3d.Set_Parameters( a, b, c );
	c3d.Exececute();
	Vectors* all_points = (Vectors)c3d.GetResult();
	break;
WM_PAINT:
	break;
}


At least all_points should be the global parameters because the one windows-thread is called again as WM_PAINT and the all_points must be lost on the memory.
That code is like the below.

switch (*event) {

WM_KEYUP:
	c3d = new Create_3D_Converter();
	c3d.Set_Parameters( a, b, c );
	c3d.Exececute();
	break;
WM_PAINT:
	Vectors* all_points = (Vectors)c3d.GetResult();
	Draw_Points(all_points);
	break;
}


and like the below.

switch (*event) {

WM_KEYUP:
	Create_3D_Converter c3d = new Create_3D_Converter();
	c3d.Set_Parameters( a, b, c );
	c3d.Exececute();
	Canvas.Set_Points((Vectors)c3d.GetResult());
	break;
WM_PAINT:
	Canvas.Draw_Points();
	break;
}


*
The function is called many times, so its stack and release of it would be a problem on the windows-thread.
On the above case, in the instance of C++ can still have the all_points on the memories until WM_PAINT calls next without any stacks.
So, C++ is very good for the windows-thread.