• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 541
  • Last Modified:

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

  • 3
  • 2
1 Solution
Have you more then 1 thread?
Do you terminate all the thread correctly before exit the application?
tsp2002Author Commented:
Have you more then 1 thread? what does that mean?
Does your application create any worker thread?
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

tsp2002Author 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
>>>> 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.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now