chazzs

chazzs

  • NA
  • 1
  • 0

thread strangeness

May 3 2005 5:02 PM
Hello. I seem to be having some threading issues with the .NET cf. I am writing a little c++ lib that allows shared memory between a .NET app and a c++/mfc app. I have a SharedMemory class written in c++ with proper exports for proper p/invokes. I have a c++ app that creates a SharedMemory object and modifies the memory through the app. Lastly i have a .NET app that does what the C++ app does. you specify the memory you want to read/write based on a name. Here is where the trouble starts. in the .NET app i start a thread that loops on a toggle bool and calls WaitForSingleObject on an event handle created when a SharedMemory object is created. The thread loops over and over doing things when the event is accually fired and not timed out by waitforsingleobject(). Now, I inserted a MessageBeep() in the loop to make it audible that the thread is running and waiting on the event. I start the app and the thread.. beep beep beep, etc. etc. when i navigate away from the app, say go to Start->Settings as soon as i navigate to settings or anywhere else for that matter, it stops beeping. Understandable that it does. But when i go back to the app, no beeping. This leads me to believe that the thread has been unexpextedly killed. How do i detect that the thread is no longer running? why does it do that? is the thread really getting killed? what is going on? thanx