|
I am having a little problem handling Threads. Problem is, there is a Thread that i want to Terminate when Destructor of a Class called. Thread function is Using some functions of that class. I have done bit reading on Threading(still learning concepts etc) and about terminating a thread the way i want to use is AfxEndThread. it must be called within the thread that has to be terminated. or can it be called outside that thread also. or is there any way to terminate that thread from outside by some other thread.
<br />
pThread = AfxBeginThread(run,&nCount,THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);<br />
pThread->m_bAutoDelete=false;<br />
pThread->ResumeThread();
thats how i am initializing the Thread. Now what if i just delete pThread object will this terminate the thread.
**************************
bit more detail...
above code is placed in the constructor of same class .. now another class when makes object of this class thread should start working and when it delets the object thread must also be end. I am getting some assertion error while some where in terminating the thread. and don't know where
|
|
|
|
|
well the Error I am getting is
Debug Assertion Failed.
File: WinCore.cpp
Line: 1002
well is this problem of my thread. :s
|
|
|
|
|
Hallo, I had a simmilar problem and I solved the problem by using a shared bool var. if the var is set to true from outside the thread terminats its self. Try to use it.
Meinhard
|
|
|
|
|
thanks for your reply well my problem solved the problem was i was trying to access a class function when there was no class object .. i mean with empty pointer .. and there was one more problem that if i start the thread again before it ends up or the class object is destroyed this create problem because thread is still using the class and class object was deleted .. so i make 2 boolean when destructor call comes one goes to false and destructor goes in an empty loop and this false boolean tell thread ok end now. before thread ends it false the other one too .. to tell destructor ok i m finish now .. so destructor comes out of loop and object destroy. it is something like syncronization .. or what ever but problem is solved
|
|
|
|
|
|
I am working on an application, in which I need to transfer the data from excel file to the access. but I don't know how to read the header row in excel file, for help, with thanks.
qqwom
|
|
|
|
|
Hi, There
I have Problem with the right way that i can Sync. Files
in two folders. i.e. when a file added in one ,a copy will add in other folder.
Folders are in Two compuer Connected with
LAN,
Is there any Sevice, Program, utility, Source code For
This?
Thanks.
|
|
|
|
|
Search CP for synchronization-type projects. Google is also a good source.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
pls tell me an API from which i can get the space of each drive and the space left in it.
thanks
|
|
|
|
|
|
iReturnValue = ::GetDiskFreeSpaceEx(drives,
(PULARGE_INTEGER)&i64FreeBytesToCaller,
(PULARGE_INTEGER)&i64TotalBytes,
(PULARGE_INTEGER)&i64FreeBytes);
TCHAR *lptotalbyte=NULL;
TCHAR totalbyte[100];
lptotalbyte=_ui64toa(((PULARGE_INTEGER)&i64FreeBytesToCaller)->QuadPart,totalbyte,10);
i used this
in my system it is showing me wrong result
if i try in other sys it is showing 0
|
|
|
|
|
|
|
Works for me. I get zero if I try it on a CD drive with no CD - GetLastError() returns 21, Device not ready.
I'd check what GetLastError() returns after the call to GetDiskFreeSpaceEx to see what the problem is.
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
|
sunit5 wrote:
lptotalbyte=_ui64toa(((PULARGE_INTEGER)&i64FreeBytesToCaller)->QuadPart,totalbyte,10);
Shouldn't this be:
_ui64toa(i64FreeBytesToCaller.QuadPart, totalbyte, 10); sunit5 wrote:
...it is showing me wrong result
How are you verifying this "wrong result?"
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
thanx MR DAVID CROW I GOT THE CORRECT VALUE
|
|
|
|
|
|
First call GetDriveTypeInfo and then GetDriveVolumeInfo. The latter will return data such as volume serial number, total disk space and free disk space
Cheers,
Tom Archer - Visual C++ MVP
Archer Consulting Group
"So look up ahead at times to come, despair is not for us. We have a world and more to see, while this remains behind." - James N. Rowe
|
|
|
|
|
|
Hi All,
I have a template class CustomList derived from MFC CList<ARG, ARG_TYPE> so that I can customize the serialization of the class
In .h file
// -------
template<typename T>
class CustomList : public CList<T,T>
{
DECLARE_SERIAL(CustomList)
public:
CustomList(): CList<T, T>()
{
}
virtual void Serialize(CArchive& ar);
};
In .cpp file
if I write
IMPLEMENT_SERIAL(CustomList, CList, 1)
I get a compiler error saying use of class template requires template argument list.
My question is how do I write IMPLEMENT_SERIAL macro so that my class is compiled correctly
Thanks
|
|
|
|
|
psychedelic_fur wrote:
My question is how do I write IMPLEMENT_SERIAL macro so that my class is compiled correctly
Have a Look At Mr. Ravi Serialize Series :-
http://www.codeproject.com/cpp/serialization_primer3.asp[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
psychedelic_fur wrote:
In .cpp file
if I write
IMPLEMENT_SERIAL(CustomList, CList, 1)
I guess, there is no .cpp file for template class. It should all be in the .h file itself.
suhredayan There is no spoon.
|
|
|
|
|
Hi to you,
I'm looking for a way to stream audio-outputs over a local net. So first I have to program a server, which listen the wav-output and secound I have to make a client which access data from the server using ftp. At the end, I can hear the same music over several floors using wlan. Could everone help me to realise this?
Thank you!
Meinhard
|
|
|
|
|