Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Print causes in afxtls.cpp

Print causes in afxtls.cpp

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++visual-studiohelp
2 Posts 2 Posters 7 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Erich Ruth
    wrote on last edited by
    #1

    I have a small program. I compile the executable. If I find the executable and double click on it, everything works fine. I can print, print preview; all is well. If within visual studio I hit the green triangle to run the executable and then I try to print or print preview, I get an error in this code:

    inline void* CThreadSlotData::GetThreadValue(int nSlot)
    {
    EnterCriticalSection(&m_sect);
    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.
    {
    LeaveCriticalSection(&m_sect);
    return NULL;
    }

    CThreadData\* pData = (CThreadData\*)TlsGetValue(m\_tlsIndex);
    if (pData == NULL || nSlot >= pData->nCount)
    {
    	LeaveCriticalSection(&m\_sect);
    	return NULL;
    }
    void\* pRetVal = pData->pData\[nSlot\];
    LeaveCriticalSection(&m\_sect);
    return pRetVal;
    

    }

    It breaks at LeaveCriticalSection(). Im really perplexed as to why this error has arisen and what to do to get it to go away. If you have any insight, please let me know.

    Richard Andrew x64R 1 Reply Last reply
    0
    • E Erich Ruth

      I have a small program. I compile the executable. If I find the executable and double click on it, everything works fine. I can print, print preview; all is well. If within visual studio I hit the green triangle to run the executable and then I try to print or print preview, I get an error in this code:

      inline void* CThreadSlotData::GetThreadValue(int nSlot)
      {
      EnterCriticalSection(&m_sect);
      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.
      {
      LeaveCriticalSection(&m_sect);
      return NULL;
      }

      CThreadData\* pData = (CThreadData\*)TlsGetValue(m\_tlsIndex);
      if (pData == NULL || nSlot >= pData->nCount)
      {
      	LeaveCriticalSection(&m\_sect);
      	return NULL;
      }
      void\* pRetVal = pData->pData\[nSlot\];
      LeaveCriticalSection(&m\_sect);
      return pRetVal;
      

      }

      It breaks at LeaveCriticalSection(). Im really perplexed as to why this error has arisen and what to do to get it to go away. If you have any insight, please let me know.

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      It would help if you gave us the details of the error you're getting. There's no way we can guess. Also, what line of code does it occur on? You have LeaveCriticalSection in three different lines.

      The difficult we do right away... ...the impossible takes slightly longer.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups