|
Hello,
ich have a question to threads and the function sleep.
We have a main programm and load from this a dll as a thread with AfxThreadStart and it is stopped with AfxThreadStop.
The dll has a method run in which is a loop which proofs a condition and runs as long as this condition is true. to stop this thread i set the condition to false. after the loop has stopped another boolean ist set to false so i know that the thread is stopped and i can delete everey references an stop the whole programm.
the pseudo code of the dll
start() {
afxThreadStart(this, true);
}
stop (){
running = false;
}
run() {
stopped = false;
while(running) {
do something
}
stopped = true;
AfxStopThread();
}
isStopped() {
return stopped;
}
I have a gui and a button, if i hit the button, the thread should be stopped and i wait until it has stopped, so i can delete all refereces to some other objects.
pseudocode for the main prog
hitButton() {
dllThread->stop();
while(!dllThread->isStopped()) {
sleep(1000);
}
delete references;
...
}
The main Problem is, that if i use the slepp method in the main Programm (see code for main prog.), it seems that the dll-thread sleeps too.
thanks for your help
Timo
|
|
|
|
|
hi,
How u knew that dll thread sleeps too ?
Regards
Velayudhan
|
|
|
|
|
Because the main prog ends and deletes all references to some objects, and then an error occurs beccause the thread still tries to use one of the objects and then everything crashes . the stop function of the main prog is faster than one iteration of the loop of the dll, so i inserted the sleep. but if i insert a AfxMessageBox bevor the sleep, then everything works fine. i dont know why, maybe the messagebox blocks the main prog and the dll-thread works and finds the stop flag.
|
|
|
|
|
Usual practice is to use an event as a trigger.
The original thread creates an event and keeps the handle to it, then creates the second thread.
The second thread does whatever it needs to do, but periodically waits for the event to be signalled. If the event is signalled, it's time to quit.
The original thread can stop the secondary by signalling the thread.
See:
CreateEvent(), SetEvent(), WaitForSingleObject() in MSDN
Steve S
Developer for hire
|
|
|
|
|
ok, thanks i'll try it as fast as i can
|
|
|
|
|
we can easy to get control when click left-mouse on button.
how do we get control when using right-mouse or
middle-mouse click during the mouse on the button?
thanks!
|
|
|
|
|
Hi,
Hope this might help you:
<a href="http://www.codeproject.com/cpp/gestureapp.asp?target=mouse%7Cgestures">http:
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
See here[^] maybe it is some helpful to you
|
|
|
|
|
michaelleetw wrote: we can easy to get control when click left-mouse on button.
how do we get control when using right-mouse or
middle-mouse click during the mouse on the button?
If you want to get a window that is under the mouse pointer use WindowFromPoint .
|
|
|
|
|
hello!! can anyone tell me how to read data from Base Address (also called as I/O Port, I/O address, I/O port Address and base port) of any device like a hard Disk? I am using inp() and outp() functions, but still not able to read data from the device. can anyone tell me how exactly i need to do that?? Thanks..
vijay.
|
|
|
|
|
On which platform, using which API, ... ?
Your post lack of information.
If you try to do that using the win32 API, I think you won't be able to do that (it is buried very deep in the core of the system and you don't have access to that).
Which device are you trying to connect ? Using which communication media ? Serial port, parallel port, ... ?
|
|
|
|
|
Hello sir!! thank for replying. Actually I am trying to Read a Sector Of the Hard Disk using the Base Address of the Hard Disk. I want to retrive the Model Number, manufacturer's serial number of the Hard Disk. i came to know from someone that all those information is stored in a sector in the Hard Disk. i have to retrive that sector to get the hard disk info. so i want to read that sector by using the Base Address of the device. The WMI classes will give the hard disk info but they dont work in Windows 9X. so, can u tell me what exactly i should do??
vijay
|
|
|
|
|
aroli vijay wrote: Actually I am trying to Read a Sector Of the Hard Disk using the Base Address of the Hard Disk. I want to retrive the Model Number, manufacturer's serial number of the Hard Disk. i came to know from someone that all those information is stored in a sector in the Hard Disk.
They are? I always thought that they were set in the firmware. On SCSI/ATAPI devices, you normally issue some 'identify' command to the device, and get the results that way.
On WinNT/XP/Server2003, you can't use inp() or outp(), although it's possible for some ports if you have a device driver. On 9x I believe that you would have to use a VXD (virtual device driver) anyway.
I'm happy to be proved wrong on any of the above, as I'd have learned something new!
Steve S
Developer for hire
|
|
|
|
|
hi how can i get total path of a file or a folder?
|
|
|
|
|
Quite obviously, if you don't have it, you have to search the entire file system to find it. You'd do better, if your list control contains files from more than one location, to store it when you are inserting the name, and know the path, for example in a map.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
ah its a my question of you in previous your thread well if you have many paths of your files you can use of a array for hold paths Is your program for open graphics files
|
|
|
|
|
Can any one say what all things we have do to change a .ocx to .exe
Rinu Raj
|
|
|
|
|
import the ActiveX component in your project...
|
|
|
|
|
thank you for your reply
but that is not what required.......
Any way i have cleared my issue
Regards
RinuRaj
|
|
|
|
|
Rinu_Raj wrote: that is not what required
not only i won't do things you could do for you, but the explaination is very poor. you don't tell what you wan't exactly, i mean, with details !
Rinu_Raj wrote: Any way i have cleared my issue
good ! then shared how you solved it !
|
|
|
|
|
i thought that there will be some complexity in converting a ocx to exe but i was wrong. I have a Dialog in my ocx anc class associated to it. So I inserted that dialog ( resource ) and dialog class to another Dialog based application and set this dialog object as the mainwindow.
Thanks
Rinu Raj
|
|
|
|
|
Rinu, i think you didn't understand my first post then...
Rinu_Raj wrote: I inserted that dialog
that's what i was saying as "importing the ActiveX (ocx) component in your project...
Rinu_Raj wrote: to another Dialog based application
...and place it in your window".
|
|
|
|
|
You have a ocx code and you want to convert this code a exe file,right?
|
|
|
|
|
Yes thats it .
I have done it. I thought that there will be some complexities but nothing was ther.
Thank you any way
Rinu Raj
|
|
|
|
|
See here[^] maybe it is some helpful to you
|
|
|
|