|
|
You may try with TerminateThread, but it's quite dangerous. Check the MSDN for list of thing which may go wrong.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
|
To "force" a thread to end, you have to use TerminateProcess, and as has been mentioned, it can be dangerous.
However, you can be more diplomatic than that. You could send your thread a Windows message, or set a shared variable (flag), to let the thread know it should quit. You will need to code up the thread so that it periodically checks to see if it should quit or not.
Even if you win the rat race, you're still a rat.
|
|
|
|
|
|
Sorry, but seems that you are a bit out of luck here
The problem is certainly the poor CFtpConnection implementation. If it blocks and never returns you just can't do a clean termination of the thread. You never now what exactly has been allocated and how to destroy these resources.
IMHO there are only two options:
1) Get rid of the damned CFtpConnection thing and choose a class that deals better. (I don't know any alternative, though I'm quite sure they exist!)
2) Kill your thread with TerminateThread(). Of course it will cause leaks. If this happens only in very rare conditions this might be acceptable. If your process is "long-running" it would be a good idea to count the number of killed threads and restart the whole process if it reaches a defined number (e.g. 10 or 20).
Yes, it's crappy - but it works and has no real harm to the system. All resources are cleaned up automatically on process termination.
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
1) Get rid of the damned CFtpConnection thing and choose a class that deals better. (I don't know any alternative, though I'm quite sure they exist!)
You need to use asynchronous sockets. They do not block and allow you to exit the thread when the socket timesout.
Todd Smith
|
|
|
|
|
You can do one of a couple things:
1. Look at the CInternetSession documentation. i think there is a way to get it so that calls can be made asynchronously - then the calls won't block completely, you'll be able to do other stuff.
2. Write your own FTP routines that don't block.
Good luck.
Even if you win the rat race, you're still a rat.
|
|
|
|
|
The wininet support asynchrnous processing , so it's perhaps your best bet ...
You should never terminate a thread by the wicked TerminateProcess() and TerminateThread !!!!!!! Period !!!! It's doesn't clean up nicely ...
You have 2 ways of stopping a threading , one is waiting the thread for finnishing , duh , the other is to signal a kernel object Event,Mutex to the thread that you want to terminate, this thread is waiting on it with a WaitForSingleObject and alike functions ...
Or you only program with Win"k or XP, you can use jobs to safely terminate a thread or a bunch of threads ... check the api CreateJobObject ... I think that VC6++ compiler if I'm not mistaken uses this technique to stop the threads ... on Win2k
Cheers,
Joao Vaz
And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary. - Shog9
|
|
|
|
|
Hi everybody,
I've implemented QueryStatus of the IOleCommandTarget interface. It looks like this:
interface IOleCommandTarget : IUnknown
{
[helpstring("method Exec")]
HRESULT Exec(
[in] const GUID *pguidCmdGroup,
[in] DWORD nCmdID, [in] DWORD nCmdExecOpt,
[in] VARIANTARG *pvaIn,
[in,out] VARIANTARG *pvaOut);
[helpstring("method QueryStatus")]
HRESULT QueryStatus(
[in] const GUID *pguidCmdGroup,
[in] ULONG cCmds,
[in,out] OLECMD *prgCmds,
[in,out] OLECMDTEXT *pCmdText);
};
But, when I try to compile the idl file I receive this error;
Creating Type Library...
Microsoft (R) MIDL Compiler Version 5.01.0164
Copyright (c) Microsoft Corp 1991-1997. All rights reserved.
Processing E:\development\COM experiments\ProxyObj\ProxyObj.idl
ProxyObj.idl
Processing D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\oaidl.idl
oaidl.idl
Processing D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\objidl.idl
objidl.idl
Processing D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\unknwn.idl
unknwn.idl
Processing D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wtypes.idl
wtypes.idl
Processing D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\ocidl.idl
ocidl.idl
Processing D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\oleidl.idl
oleidl.idl
Processing D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\servprov.idl
servprov.idl
Processing D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\urlmon.idl
urlmon.idl
Processing D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\msxml.idl
msxml.idl
E:\development\COM experiments\ProxyObj\ProxyObj.idl(59) : error MIDL2025 : syntax error : expecting a type specification near "OLECMD"
E:\development\COM experiments\ProxyObj\ProxyObj.idl(59) : error MIDL2026 : cannot recover from earlier syntax errors; aborting compilation
Error executing midl.exe.
ProxyObj.tlb - 2 error(s), 0 warning(s)
Any idea why? Should I include something special?
Thx,
/Tommy
|
|
|
|
|
this is code of gotoxy, i have made in c++ using assembly, but it is not working and giving an error of invalid operand.
plz help!!!!
void _gotoxy(int row,int cols)
{ asm MOV AH,0x2
asm MOV DH,row// problem is here,if we use
asm MOV DL,cols//constant here, it works
asm MOV BH,0x0
asm INT 0x10
}
void main()
{ clrscr();
_gotoxy(15,15);
printf("x");
getch();
}
|
|
|
|
|
Just a guess (it's been a long time ), but aren't DH and DL only 8 bits?
Try this:
void _gotoxy(int row, int col)
{
asm
{
mov ah, 2
mov bh, 0
mov dh, row & 0xff
mov dl, col & 0xff
int 0x10
}
}
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
i have checked that but it is not working, suggest any thing else, plz help!!!!
|
|
|
|
|
The only other thing I can think of would be to use char instead of int .
void _gotoxy (char x, char y)
otherwise I have no idea why it would work with a constant and not a variable. I do not have Turbo C++ to test it myself. What does your manual say about using variables in inline assembly?
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
Hey Im not a real advanced programer or anything, but when I use Turbo C++ in class, I can include <stdio.h> and freely use gotoxy(int,int); thoughout the program to move the cursor to a certain spot on the screen and print something there. What the hell is up with visual c++. It's telling me that gotoxy(int,int); is an "undeclared identifier". Well Im lost...
|
|
|
|
|
I'm looking for a (speedy) class/algorithm to convert Paradox/Excel date serials to a day-month-year value and back.
VictorV
|
|
|
|
|
|
The Paradox/Excel serial date is the number of days since 1-1-1900. I was wondering if anyone knew a fast algorithm to convert a serial date to day-month year and vise versa...
VictorV
|
|
|
|
|
Hello,
I need to change the font of a property sheet tab from the same tab.
Let's say that in that tab there is the control of alarms and emergencies that can happen in a machine that I control. when a new alarm or emergency happens I want to be able to change the color of the "alarms and emergencies" tab.
As always thank you in advance.
NOTE:
I want only to change the font of the "alarms and emergencies" tab, the other ones should keep the same font than before.
|
|
|
|
|
|
There is a function SetAutoURLDetect suporrted by CRichEditCtrl as per MSDN but when actually called there is no such function in the header file . there is a compiltion error can anybody help me ?????
|
|
|
|
|
|
|
I have a initialized a bitmap with a bitmap info header,which i have mentioned of bitcount=1(monochrome bitmap).I want to get the bits of the bitmap.Is it possible to get the bits by using function called GetDIBits for a monochrome bitmap.
|
|
|
|
|
Is there any reason you can't create it as a DIBSECTION ? Then you'll have a pointer to the bits by default.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
|
|
|
|