|
Hi,
I created a thread using the AfxBeginthread function.
How do I stop this thread from another thread. MSDN resources say that its dangerous to use call TerminateThread. I tried using it too, but it failed to terminate it.
Thanks,
Deepak Samuel.
|
|
|
|
|
one way is to set a global boolean flag like g_fExit = true, from whichever thread you want ..so that the corresponding thread sees that and return.
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
in case you wanna use that call InterlockedIncrement or use a Critical section object in order to prevents more than one thread from using the same variable simultaneously.
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Check the CEvent for MFC or the events in general for WIN32
The main idea:
in the loop of the thread that you want to stop, call WaitForSingleObject with WAIT_OBJECT_0 on the event handle, and in case it is signaled you just have to return and in the other thread just signal the event
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
i told that was one way and perhaps the simplest.
see wot Jeffery Ricther has to say. [^]
"its easy to make complex and complex to make simple"
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
Both are easy and simple to use, but i would rather go with events as it sure that it would be thread safe.
God is Real, unless declared Integer.
|
|
|
|
|
sounds nice..
please explain the need for thread saftey for this line:
g_fExit = true
that also with the help of an MFC object !
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
No, i am not tring to be within the context on this problem only... In general senario where threads need to be syncronised i would use kernel objects rather than some variables.;)
God is Real, unless declared Integer.
|
|
|
|
|
it 'd 'nt be fair if i dont mention the risk of deadlock. For any big and complex program it 'd be programmers nightmare to maintain all those handles.
if he has lot of threads and want to stop them form others. seems you didnt faced any such problem yet.
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
suhredayan® wrote:
if he has lot of threads and want to stop them form others
thats what kernel object are for, using it efficiently gives good results.
God is Real, unless declared Integer.
|
|
|
|
|
i would be greatful if you explain the pitfall in following line if executed from multiple thread.
g_fExitThread=true;
or atleast the need from the kernal resource, to do the above.
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
Click[^]
God is Real, unless declared Integer.
|
|
|
|
|
suhredayan® wrote:
see wot Jeffery Ricther has to say.
either Jeffery is ur pal ,or you been eating pages of his book.
God is Real, unless declared Integer.
|
|
|
|
|
maatha>pitha>guru>god
btw not a pal, but > god
thats wot i have learnt.
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
PostThreadMessage(ThreadId, WM_QUIT, 0, 0);
|
|
|
|
|
The problem with using PostThreadMessage or SendNotifyMessage is that worker threads typically don't have message loops, so these functions are not helpful always.
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
Hi all..
I want to find the type of internet connection.Is there any method to find the type of internet connection used by a particular system.
|
|
|
|
|
do you mean you want ethereal application ?
TOXCCT >>> GEII power
|
|
|
|
|
Hi,
I have built a software in VC++, and prepare two icons for the software,
one small size icon for software .exe file icon, and one large icon for the shortcut of the exe in the desktop.
What should I do in the program that associate the two icons to the code so that it works like what i want?
Thanks
|
|
|
|
|
Go and edit the resources icons, and when you click on that you'll see a drop down and in it the size of the icon in order to select the small or the large one.
You have two choices, copy paste the icon image into the resource of each one and save then build your application or replace the icon file path when you right click and propreties on that icon
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Is there any way to apply a rotation matrix to a CDC blt? I am trying to draw a rotated bitmap..
|
|
|
|
|
in NT we have PlgBlt which is not available on 98/ME
there are a few articles on CP that rotate an image
here[^]
i can't even remember what my point is now, but anyway, i'm correct
Barring unforeseen acts of God and Adminstrators, my server will be up tomorrow. I'm more worried about the Adminstrators.
|
|
|
|
|
there you go.
the comments are in german, if you have questions feel free to ask.
void CWool5View::drehe_bild()
{
int x,y;
int xx,yy;
int mipux,mipuy;
double a,r,h;
double pih=3.14159;
BeginWaitCursor();
CClientDC dc(this);
int miny,maxy;
if(rot_l_y<rot_r_y)
{
="" miny="rot_l_y;
" maxy="rot_r_y;
" }
=""
else
="" }
dc.bitblt(="" rot_l_x-20,
="" miny-20,=""
="" rot_r_x-20,="" maxy-20,="" m_pdcmemory,
="" rot_l_x-20-start_videox,="" miny-20-start_videoy,="" srccopy);
="" drehwinkel="" berechnen
double="" rotation;
if(rot_l_y="=rot_r_y)
" rotation="0.0;
else
" ((double)rot_r_x-(double)rot_l_x)="" ((double)rot_r_y-(double)rot_l_y)="" );
="" if(rot_l_y<rot_r_y)
="" }
="" else
="" rotation*="-1.0;
" }
mipux="(int)(float)BMP_width/2.0;
mipuy=(int)(float)BMP_height/2.0;
for" (x="0;" x="" <="" bmp_width;="" ++x)
{
for="" (y="0;" y="" bmp_height;="" ++y)
="" den="" winkel="" aus="" aktuellen="" x,y="" koordinaten="" errechnen.
="" if(x-mipux!="0)
" h="((double)y-mipuy)/((double)x-mipux);
" a="atan(h);
" quadrant="" links="" oben
="" if(="" (x-mipux<0)="" &&="" (y-mipuy<="0))
" a+="pih;
" r="sqrt(((x-mipux)*(x-mipux))" +="" ((y-mipuy)*(y-mipuy))="" );
="" xx="(r*cos(a));
" yy="(r*sin(a));
" if((mipux-xx<0)="" ||="" (mipux-xx="">videogroessex) || (mipuy-yy<0) || (mipuy-yy>videogroessey))
dc.SetPixel(start_videox+x, start_videoy+y, RGB(0,0,0));
else
dc.SetPixel(start_videox+x, start_videoy+y, m_pdcMemory->GetPixel(mipux-xx, mipuy-yy));
}
//quadrant rechts unten
else if( (x-mipux>=0) && (y-mipuy>0))
{
//a+=pih;
r=sqrt(((x-mipux)*(x-mipux)) + ((y-mipuy)*(y-mipuy)) );
a+=rotation;
xx=(r*cos(a));
yy=(r*sin(a));
if((mipux+xx<0) || (mipux+xx>videogroessex) || (mipuy+yy<0) || (mipuy+yy>videogroessey))
dc.SetPixel(start_videox+x, start_videoy+y, RGB(0,0,0));
else
dc.SetPixel(start_videox+x, start_videoy+y, m_pdcMemory->GetPixel(mipux+xx, mipuy+yy));
}
//quadrant links unten
else if( (x-mipux<0) && (y-mipuy>0))
{
//a+=pih;
r=sqrt(((x-mipux)*(x-mipux)) + ((y-mipuy)*(y-mipuy)) );
a+=rotation;
xx=(r*cos(a));
yy=(r*sin(a));
if((mipux-xx<0) || (mipux-xx>videogroessex) || (mipuy-yy<0) || (mipuy-yy>videogroessey))
dc.SetPixel(start_videox+x, start_videoy+y, RGB(0,0,0));
else
dc.SetPixel(start_videox+x, start_videoy+y, m_pdcMemory->GetPixel(mipux-xx, mipuy-yy));
}
//quadrant rechts oben
else if( (x-mipux>=0) && (y-mipuy<=0))
{
//a+=pih;
r=sqrt(((x-mipux)*(x-mipux)) + ((y-mipuy)*(y-mipuy)) );
a+=rotation;
xx=(r*cos(a));
yy=(r*sin(a));
if((mipux+xx<0) || (mipux+xx>videogroessex) || (mipuy+yy<0) || (mipuy+yy>videogroessey))
dc.SetPixel(start_videox+x, start_videoy+y, RGB(0,0,0));
else
dc.SetPixel(start_videox+x, start_videoy+y, m_pdcMemory->GetPixel(mipux+xx, mipuy+yy));
}
}
}
|
|
|
|
|
Since I have made some modifications in the menu "Project" "Settings", my debugger doesn't give me the evolution of the values of the variables I use.
I have always this type of error for all my variables:
m_bCommunicationMode CXX0017: Error: symbol "m_bCommunicationMode" not found
Is there something to modify ?
Thank's for advance
|
|
|
|
|
The only thing I can think of, which I bet you have tried. Rebuild the whole project.
Larry J. Siddens
|
|
|
|