Click here to Skip to main content
11,483,586 members (70,341 online)
Click here to Skip to main content

Tagged as

Using CAtlArray for a class member variable

, 8 Oct 2012 CPOL 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.

6 Oct 2012
Briti 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.
8 Oct 2012
Briti 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...
6 Oct 2012
Michael N 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;}...
9 Oct 2012
Michael N Haephrati (האפרתי)
How can I get notified, to the main even loop when this thread completes?
8 Oct 2012
Michael N 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...
6 Oct 2012
Michael N 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.
9 Oct 2012
Briti 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)

Share

About the Author

Briti Sundar
Software Developer Worked in a Research & Development Center
United States United States
No Biography provided

| | Privacy | Terms of Use | Mobile
Web02 | 2.8.150520.1 | Last Updated 8 Oct 2012
Article Copyright 2012 by Briti Sundar
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid