|
How would the thread function declaration look like?
|
|
|
|
|
|
_beginthread(DownloadThread, 0, (void*) NewDownload);
void DownloadThread(void *D)
{
CDownload *Download = (CDownload*)D;
}
Compiles, but once the _beginthread is called the program crashes!
modified on Monday, April 26, 2010 3:39 PM
|
|
|
|
|
How is NewDownload declared?
|
|
|
|
|
1) Window that accepts URL
2) Pressing OK
3) Break down URL store it in CDownload *NewDownload;
4) After NewDownload has been filled out.
5) I pass NewDownload to download function to test if it the download function works
6) Add NewDownload to Linked List
Production code, user will be able to pause/resume called the download thread
|
|
|
|
|
Declaration, not implementation or use. In other words, is NewDownload a CDownload object?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
|
It seems passing Class Object part of a Linked List doesn't not work in this traditional manner!
|
|
|
|
|
Try something like this -
CDownload* NewDownload = new CDownload;
_beginthread(MyThreadFunction, 0, (void*)NewDownload);
|
|
|
|
|
How would the MyThreadFunction declaration look like?
void MyThreadFuction (void* Download)
{
char *HostName = new char[wcslen(Download->HostName)+1];
}
error C2227: left of '->HostName' must point to class/struct/union/generic type
|
|
|
|
|
void MyThreadFuction (void* Download)
{
CDownload* NewDownload = (CDownload*)Download;
char *HostName = new char[wcslen(NewDownload->HostName)+1];
}
|
|
|
|
|
Thank You for your patience.
Actually I had done that same workaround fix, but since of my inexperience I thought I was doing it wrong.
As it appears I found another reason causing the disruption which has caused all this fuss.
Since I'm using long long, doing a percentage calculation. However because of 0 being part of my calculation. It crashes! Bringing up lldiv.asm to Line 121 due to the 0 value. Anyway I will try understand went wrong later. Thanks again for your help Nameless MVP!
|
|
|
|
|
I briefly talk about this here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I remember reading that - a great piece of code (not that you need me to tell you)
I'm sure someone was asking about printer notifications recently here on CP as well, so your article was timely.
'g'
|
|
|
|
|
<pre>_beginthread(MyThreadFunction, 0, NULL);
Tried to pass a value like in regular C++ functions.
_beginthread(MyThreadFunction(MyData), 0, NULL);</pre>
look at how you call _beginthread and combine what the other people have already posted. You have the idea, but just look at how _beginthread is defined.
~ELChupathingy
|
|
|
|
|
Here's a nice writeup[^] on the subject. He emphasises on MFC, but the idea is the same.
A book on threading would be of immense help to you.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
So in a normal C++ environment you can use fstream!
CFile in MFC applications, does anyone know of other file writing functions that don't involve MFC.
While also restricting output with number of bytes to write?
|
|
|
|
|
Fareed Rizkalla wrote: does anyone know of other file writing functions that don't involve MFC.
How about WriteFile() and fprintf() ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
You could start here[^] and work your way up. The basic IO functions require you to do all the work, in terms of formatting your data.
It's time for a new signature.
|
|
|
|
|
I have a lot of legacy code using fprintf(stderr, .....); I also have monitoring pane which is a CEdit control. How can I redirect stderr to output into the CEdit control?
I have a look around but most of the answers involve the creation of a new process. Is any simpler way of doing it? Effectively what I 'd like to do is something like
start redirection of stderr to myEditControl;
fprintf(stder, ....);
finish redirection of stderr
Thanks
|
|
|
|
|
It's not a trivial task. See here and here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Thanks, I have already looked at it but they involve a CreateProcess call. Which means an extra process. This is what I want to avoid actually.
|
|
|
|
|
Have anybody compile PDFlib Lite 7.0 to get pdflib.lib file ? PDFlib offer a lite version of their library , 7.0.4 , but must compile to obtain a valid library ... I don't know how ! Can anybody help me ? Source code is here , only must download , compile to get pdflib.lib file ... My error is :
LINK : fatal error LNK1181: cannot open input file "pdflib.lib" , or really this I want to get it !
|
|
|
|
|
Looks like you are trying to include a library file that does not exist. Have you successfully compiled all the source files?
It's time for a new signature.
|
|
|
|
|
I downloaded and extracted all the source.
I opened the PDFlib.dsw and had VS2005 convert all projects. (The ZIP is for VS6 and I'm using VS2005)
I rebuilt the DEBUG PDFlib project only and it successfully produced the PDFLib.lib file.
When compiling however it will generate a lot of warnings about unsafe functions.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
|
|
|
|