[Mono-dev] Threads sleeping forever

Darkiwi pitikiwi_001 at hotmail.com
Tue Jul 5 10:31:43 EDT 2011


In the main thread, the launching of the tests :

/         mCommandThread_O = new Thread(BgTask);
         mCommandThread_O.Priority = ThreadPriority.Highest;
         mCommandThread_O.IsBackground = true;
         mCommandThread_O.Name = "Protocol State Machine " +
Index_i.ToString();
         mCommandThread_O.Start();/

The test thread :

/    private void BgTask()                         /*! State machine of the
command thread           */
     {
       UInt32 RetCode_U32 = 0;
        while (true)
       {
         try
         {
           Multiplexing();                                           // Is
there a command to send?
            if (mCmdToProcess_O.Command_E != ProtocolCommands.NoCommand)
           {
             RetCode_U32 = ExecuteCmd();                             // We
send the command
              if (RetCode_U32 == CsApi.BOFERR_NO_ERROR)               //
Success => we process the answer
             {
               ProcessAnswer();
               mNbError_U32 = 0;
             }
             else                                                    //
Error
             {
               ProcessError();
               mNbError_U32++;
             }
             Thread.Sleep(0);
           }
           else
           {
             Thread.Sleep(10);
           }
         }
         catch Exception (_Except_O)
         {
           Console.WriteLine(_Except_O.ToString());
         }
       }
     }/

But I doubt that the thread loop is the culprit because I've tried
commenting all of it and I still sometimes get stuck in the sleep --> it's
probably the main thread deadlocking somehow...

Also, when I launch too many tests alltogether and they sleep, my app dumps
and I get an exception :

"System.Threading.ThreadAbortException: Thread was being aborted
  at (wrapper managed-to-native) System.Threading.Thread:Sleep_internal
(int)
  at System.Threading.Thread.Sleep (Int32 millisecondsTimeout) [0x00000] in
<filename unknown>:0"

--
View this message in context: http://mono.1490590.n4.nabble.com/Threads-sleeping-forever-tp3646037p3646117.html
Sent from the Mono - Dev mailing list archive at Nabble.com.


More information about the Mono-devel-list mailing list