|
Perspx wrote: If they know something then they'll reply to your question
if they understand the question as well...
|
|
|
|
|
Yes
Regards,
--Perspx
"The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia
Introduction to Object-Oriented JavaScript
|
|
|
|
|
The below mentioned code Working fine in the first run, but crashes in the second run
---------------------------
nav.exe - Application Error
---------------------------
The instruction at "0x000003f8" referenced memory at "0x000003f8". The memory could not be "read".
Click on OK to terminate the program
Click on CANCEL to debug the program
---------------------------
OK Cancel
---------------------------
.h
typedef struct THREADSTRUCT_SCOPE
{
long maxRowCount;
AttMap selection;
MsgList *results;
AOL *assets;
THREADSTRUCT_SCOPE( const Scope* ptr )
: _this( ptr )
{} const Scope *_this;
} THREADSTRUCT_SCOPE;
THREADSTRUCT_SCOPE *_param;
.cpp
<pre>
SysScope::SysScope
(
)
{
_param= new THREADSTRUCT_SCOPE( this );
}
SysScope::~SysScope()
{
delete _param;
}
bool Scope::genericSearchByAtt
(
const long maxRowCount, // I: Maximum number of rows to return
const AttMap& selection, // I: Selection attributes
MessageList& results, // U: Result
AOL& assets, // O:
int ObjectType //
)
const
{
invalidArgAssert(maxRowCount > 0 &&
selection.contains(Id::Attr_ClassType));
.....
...
....
assets.push_back(asset);// CRASHES HERE only druring Second run
}
bool Scope::searchByAttributes
(
const long maxRowCount, // I: Maximum number of rows to return
const AttMap& selection, // I: Selection attributes
MsgList& results, // U: Result messages are appended
AOList& assets // O: Asset objects
)
const
{
HANDLE hThread;
_param->assets = &assets;
_param->maxRowCount = maxRowCount;
_param->results = &results;
_param->selection = &selection;
hThread=(HANDLE)_beginthreadex(0,0,WorkerThread,(void*) _param,0,0);
while (1) //iThDone!=1
{
if (iThDone==1)
break;
DoEvents9();
}
return true;
}
unsigned __stdcall Scope::WorkerThread(void* param)
{
THREADSTRUCT_SCOPE* ts = (THREADSTRUCT_SCOPE*)param;
BASE_ASSERT(ts->_this->genericSearchByAtt(ts->maxRowCount,
*ts->selection, *ts->results, *ts->assets, Asset::Type) );
iThDone=1;
return 1;
}
modified on Monday, August 25, 2008 3:07 AM
|
|
|
|
|
you may be using a out of bounds value or some uninitialized variable/pointer in the second run.
Did you try and debug the application to check what values reside in the variable during second run?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Any clue from the above code, Since I am using thread, The fuction which is called from thread for second time is failing, Is that the thread is still active when calling for second time or some thing like that
so can you pls advice
|
|
|
|
|
|
ptr_Electron wrote: Working fine in the first run, but crashes in the second run
Second run means - during the first function call its working and if you call it once again it crashes?
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Yes correct, If I call ther thread function for second time it crashes..
|
|
|
|
|
I am done with that thanks
|
|
|
|
|
ptr_Electron wrote: while (1) //iThDone!=1
{
if (iThDone==1)
break;
DoEvents9();
}
I guess you use this mechanism to wait until the thread get finished. Well, i assume the iThDone is a global variable.
Well, I can imagine a detective story.
1) All the reference variables pass to Scope::searchByAttributes() is on stack. (May be the class SysScope is used for that)
2) During the first run, the value of iThDone is 0 and your waiting mechanism works well.
3) But during next function call, you are not resetting the iThDone as 0 before creating the thread. Its still 1.
4) So your wait loop will exit immediately instead of waiting for the thread to get finished.
5) The main thread stack will be un-winted and the assets will get deleted. (May be via SysScope::~SysScope() ).
6) But your worker thread is still under execution and it tries to access the vector and hence the crash.
Suggestion
1) instead of this while loop waiting mechanism, just use WaitForSingleObject()[^]. Its a blocking call and the next line will execute only when your thread get finished. Call it like this
hThread=(HANDLE)_beginthreadex(0,0,WorkerThread,(void*) _param,0,0);
WaitForSingleObject( hThread, INFINITE );
2. One more suggestion. In SysScope::~SysScope() , after deletion set the pointer as null. So that you can the problems more easily due to null pointer exceptions.
If still the problem is not solved, ping back. Well, I apologize for a very big post.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Hi all,
I am having a dll(c#) and i want to use it in my vc 6 program,i.e. i want to call a function from that dll....
how can i do this...
Thanks in advance
|
|
|
|
|
// Import the type library.
#import "..\Debug\MyManagedDll.tlb" raw_interfaces_only
and then use
HRESULT hr = CoInitialize(NULL);
ISomePtr pIptr(__uuidof(My_managed_class_uuid_goes_here));
long lResult = 0;
pIptr->Func(5, 10, &lResult);
CoUninitialize();
return 0;
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
no that not that simple, see that DLL is written in C# and the programmer want to call it in VC 6..
please follow this tip
How to call a COM C# component from VC++?[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
yeah! probably I overlooked the scenario of registering the managed dll using regasm and also the 'using namespace' part which is so common in managed code
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
naah! i am too very new to managed world.. still I am living on bridge between managed and unmanaged world
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
|
In a dialog based program, I insert a MS FlexGrid control, and I stretch the grid to fill the rect as I want. But use SetColWidth not set the column as wide as I want.
my code below:
m_grid.SetRows(3);
m_grid.SetCols(2);
m_grid.SetRow(0);
m_grid.SetCol(0);
m_grid.SetText(_T("name"));
m_grid.SetRow(0);
m_grid.SetCol(1);
m_grid.SetText(_T("age"));
CRect rcGrid;
m_grid.GetClientRect(&rcGrid);
int iColWidth = 0;
iColWidth = rcGrid.Width()/2;
m_grid.SetColWidth(0, iColWidth);
m_grid.SetColWidth(1, iColWidth);
BTW, is there any links I can get help of MS FlexGrid or code samples? So I don't have to ask every functions here!
modified on Monday, August 25, 2008 4:21 AM
|
|
|
|
|
|
Please help us to include transparent dialogs in our project.
|
|
|
|
|
You've to go for layered windows. Refer this excellent Article by Paul DiLascia.[^]. It describes everything in detail with code snippets.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
See here[^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hi,
I want to need of copy file/Folder information(File Name,File Path,File Data ...) which is currently copy.
secondly I want to need same for Paste file/Folder information.
Thanks
Anubhava Dimri
|
|
|
|
|
Do you want to track copying of folders/files?
If positive, See Here[^] & here[^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hai..
This link gives about Edit, combobox,static text, list controls,etc., but no group box control. Please tell me any other source. Thanks to all.
Regards,
Selvan.S.
|
|
|
|
|
can you please carry on with the same thread. you have a link to reply in the posts that you can use to post response to the same thread. This is not a chat forum and so no need to open new threads.
Selvan.S wrote: This link gives about Edit, combobox,static text, list controls,etc., but no group box control
If you know how to do a thing for either of the control you can most of the times use it for other controls too...
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|