Click here to Skip to main content
15,883,901 members
Articles / Desktop Programming / ATL

Using CAtlArray for a class member variable

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
8 Oct 2012CPOL 0   11  
It will be better if you post a little bit of code. However,suppose classname is MyClass and your thread name MyThread. You call this thread from your class. then try this.._beginthread(MyThread,0,this);void* MyThread(void* arg){ MyClass* newObj = (MyClass* )arg; // now...

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
6 Oct 2012Briti Sundar
May be you have missed to malloc first before insert into MyArray.MyDataStructure* pNewStruct;pNewStruct =(MyDataStructure* )malloc(sizeof(MyDataStructure));MyArray.Add(pNewStruct);Hope this will work.
Please Sign up or sign in to vote.
8 Oct 2012Briti Sundar
This work for me and i get value after thread exit. Compare your code with me , you can understand your problem. Another thing CreateThread can not call a member function, so you must need a static function for this.,#include "stdafx.h"#include #include #include #include class...
Please Sign up or sign in to vote.
6 Oct 2012Michael Haephrati 7 alternatives  
I would appreciate it if someone can provide me with a code sample for using CAtlArray as a member variable inside a class, where the array should hold a custom data structure.I have defined the data structure:typedef struct{ int Status; CTime StatusDate;}...
Please Sign up or sign in to vote.
9 Oct 2012Michael Haephrati
How can I get notified, to the main even loop when this thread completes?
Please Sign up or sign in to vote.
8 Oct 2012Michael Haephrati
Something like// testproject.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include #include #include typedef struct{ CString FullPath; CTime StatusDate;} Item;class MyClass{public: MyClass(); ~MyClass(); void...
Please Sign up or sign in to vote.
6 Oct 2012Michael Haephrati
[ bappycse05] is correct but I also used a Thread which is a member function of a class and wanted it to access the class's member variables, but the moment the thread ends, any changes it makes in any member variables are erased.
Please Sign up or sign in to vote.
9 Oct 2012Briti Sundar
Use this ---dwRet = WaitForSingleObject(HANDLE,TIME);see the example .. http://www.installsetupconfig.com/win32programming/threadprocesssynchronizationapis11_13.html[^]when thread will be completed, use postmessage method to inform UI :D

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Worked in a Research & Development Center
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions