|
masnu wrote: so my main thread can know if the workher thread terminated with an error.
What error? Use of thread exit codes are most often replaced with a form of communication of your own design. You are doing Object Oriented Programming aren't you?
led mike
|
|
|
|
|
The exit code I want is the one I have defined as nError in the above example. Based on that number I can determine why the thread exited.
|
|
|
|
|
From your code, I can say that you need:
1. return the error code in your thread function Connect(void* param)
2. From the main thread you can call GetExitCodeThread
Better solution is something like Mike suggested, define an interface to receive the error or success is much better.
God bless,
Ernest Laurentin
|
|
|
|
|
Your assumption is correct. You can return nError and then read that number via GetExitCodeThread from the main thread.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
|
O M G
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am coding under vc 6.0
every time I debug, I find that if a list is pointed by the pointer,
I can only see the first content of the list in the watch window, any ideas how to watch all the list ?
PS. some say we can see them in a memory window but it is too hard to read.
some say I can indicate the specific index of the list ,say list[5], but I want to see all the content in a list.
|
|
|
|
|
a pointer is only an address in memory.
if you handle an array, you actually use a pointer to the 1st element.
the VC6 debugger is not very powerful (actually, VC6 itself is far outdated by its new versions).
so if you want to see the other elements, you have to specify yourself the address of the element you need to watch AFAIK...
|
|
|
|
|
toxcct wrote: the VC6 debugger is not very powerful (actually, VC6 itself is far outdated by its new versions).
so if you want to see the other elements, you have to specify yourself the address of the element you need to watch AFAIK...
you are correct, But viewing the List items is very simple from VC6.0, we don't want to explicitly specify the address of the next element, it shows tree view in the watch window and expands the list if the first element is in the watch window.
struct ListNode
{
int iData;
struct ListNode *pNext;
};
int main(int argc, char* argv[])
{
struct ListNode Head, Middle, Tail;
Head.pNext = &Middle;
Middle.pNext = &Tail;
Tail.pNext = 0;
return 0;
}
I can view the list items in the above program as tree view in the watch window of VC6.0, even VC6.0 supports drag and drop variable to watch window.
|
|
|
|
|
I know what is a linked list, but I don't think the OP is using them at all.
hence my reply, refering to arrays and pointer arithmetic. I think he used the term "list" when he wanted to say "array"...
|
|
|
|
|
toxcct wrote: I think he used the term "list" when he wanted to say "array"...
struct ListNode list[3];
struct ListNode *plist = list;
still i can view as tree control of array element with tree labels like [0], [1], [2] .. in VC6.0 watch window
when watching variable as "list" and "plist,3"
|
|
|
|
|
I think in VC6, you can type something like: 'list,m' in the watch window
This will show you the entire memory. VS2003, 2005, 2008 supports this.
God bless,
Ernest Laurentin
|
|
|
|
|
thanks , you answer is right.
|
|
|
|
|
I have a CListBox in which I display a string using the AddString function
For the CString I use it's Format Function
CListBox List1;
CString str;
short Data[50];
int DataSize ; /* variable */
DataSize = /*some processing */
for ( i=0;i<j;i++)
{
/* some other processing*/
str.Format("%X ",Data[i]);
List1.AddString(str);
}
My current code Data is outputed in this manner
05
25
6F
E2
I want my display to be like this :
Contents of Data[DataSize-1] Contents of Data[DataSize-2] .... Data[0]
e.g if Data[0]= 05 Data[1]= 25 Data[2]=6F and Data[3]= E2
Display I want is
E2 6F 25 05 (ie in the same line )
How do I go about doing it ? any help woould be appreciated
|
|
|
|
|
Use AppendFormat() in place of Format(). And Addstring to the list when you complete the line.
And Are you expecting data in separate column?
|
|
|
|
|
Is AppendFormat present CString Function in VC++ 6.0 ?
|
|
|
|
|
Are you expecting data in separate column?
|
|
|
|
|
I want data to displayed like this
25 4E 20 F6 .... (for example)
and not like this
25
4E
20
F6 ( I dont want for it to displayed in Different rows but all in the same row)
|
|
|
|
|
Then I am not sure AppendFormat is supported in VS 6.0. But i think it should have concatenation operator. Format using temp variable and concatenate to main string.
If want in separate column go for ListView control, CListCtrl.
|
|
|
|
|
You can concatenate all hex. digits in one string. As shown below:
CString strLine;
for ( i=0;i<j;i++)>
{
/* some other processing*/
str.Format("%X ",Data[i]);
strLine += str;
}
List1.AddString(strLine);
In this approach, you can also use tab ('\t') separator char. between numbers, then you can use CListBox::SetTabStops() function in order to display it properly.
If you want to have real tabular view, you can employ CListCtrl (list view control) instead of CListBox.
|
|
|
|
|
thanks that does it
I am new to C++
|
|
|
|
|
it's because you're using a List control, and you're setting each string on a line.
you have to build the single string, and do the List1.AddString() after the for() loop...
|
|
|
|
|
toxcct wrote: it's because you're using a List control...
How did you infer this?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: How did you infer this?
List1.AddString() is explicit enough...
|
|
|
|
|
Isn't Addstring() for listboxes?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|