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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Console Hangs after printf.

Console Hangs after printf.

Scheduled Pinned Locked Moved C / C++ / MFC
csharpdebuggingvisual-studiohelpquestion
2 Posts 2 Posters 0 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.
  • B Offline
    B Offline
    Brian van der Beek
    wrote on last edited by
    #1

    We are using Visual Studio .Net and dump a lot of debug info of our application to a console. Normally this is not a problem, however sometimes the console hangs and I cannot set the focus to the debugger anymore. And if I start the task manager, the whole system seems to hang. We do use multiple thread to log information to the console, so I created the threads with _beginthreadex instead of CreateThread, but that does not seem to make any difference. Any one got a clue why this might be happening?

    C 1 Reply Last reply
    0
    • B Brian van der Beek

      We are using Visual Studio .Net and dump a lot of debug info of our application to a console. Normally this is not a problem, however sometimes the console hangs and I cannot set the focus to the debugger anymore. And if I start the task manager, the whole system seems to hang. We do use multiple thread to log information to the console, so I created the threads with _beginthreadex instead of CreateThread, but that does not seem to make any difference. Any one got a clue why this might be happening?

      C Offline
      C Offline
      CodeBeetle
      wrote on last edited by
      #2

      Maybe you need to make calls to printf thread safe, by using a CRITICAL_SECTION object.... void theadsafe_printf(char *lpzText) { EnterCriticalSection(&cs); printf("%s",lpzText); LeaveCriticalSection(&cs); } Use InitilizeCriticalSection() to create the cs object. and DeleteCriticalSection() when finished at the end of your app.


      CodeBeetle.Com


      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