Need some help with my program MFC

my SDI runs fine. When I close it I get a stop afxtls.cpp (see below)
What kind of error is this?
Please help.
500 poinst.
Best regards,

inline void* CThreadSlotData::GetThreadValue(int nSlot)
	ASSERT(nSlot != 0 && nSlot < m_nMax);
	ASSERT(m_pSlotData != NULL);
	ASSERT(m_pSlotData[nSlot].dwFlags & SLOT_USED);
	ASSERT(m_tlsIndex != (DWORD)-1);
	if( nSlot <= 0 || nSlot >= m_nMax ) // check for retail builds.
		return NULL;<---------------------------------------stops here

Open in new window

Thomas StockbrueggerAsked:
Who is Participating?
>>>> Does your application create any worker thread?

The CThreadSlotData class in MFC was used for single threaded applications as well.

IMO, the error has nothing to do with threads. The assertion most probably came because of a precompiled headerfile which was out-of-date. Then, any of the members m_sect, m_nMax or m_tlsIndex got corrupt and you got an assertion.

a thread is own branch of execution in a process. Each process has at least one thread, the main thread. You can by code create a second (or more) thread which would asynchronously run parallel to the main thread, e. g. to make a calculation or read an imgae from a file, or similar. If you create a thread you pass a function with the thread which then was executed.

an assertion is a statement which breaks in the debugger if the condition in the argument was false:

   ASSERT(nSlot != 0 && nSlot < m_nMax);

would bring an error and break in the debugger if either the argument nSlot is 0 or if nSlot is greater or equal to m_nMax (what is a member of the class CThreadSlotData). Such assertions are a means to program a precondition for a function. It normally would never fail after the developing phase beside there is something really wrong with your build or with a new call you made to a MFC function. E. g. if you call a dialog by pointer where the dialog already was closed, you fastly will run into some assertion which tells you that the windows handle isn't valid or some other error. So, if you come to an assertion, you firstly make a rebuild and if that doesn't help, you look to the call stack whether there is some new statements you made which were seomehow wrong.
Have you more then 1 thread?
Do you terminate all the thread correctly before exit the application?
Thomas StockbrueggerAuthor Commented:
Have you more then 1 thread? what does that mean?
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Does your application create any worker thread?
Thomas StockbrueggerAuthor Commented:
I jused used button project clean
and project rebuild before I started with debug button.
(the button names could be different at your version)
Now the error is gone???
I don´t know why.
Does your application create any worker thread?What is a thread??? sorry
If you don't know what a thread is, you couldn't create one...    ;-)

For more informations give a look at
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.