Main Site Documentation

Thread.Start() exception


#1

Hi

I am getting a thread.Start exception using V4.1 on Fez Cobra, any ideas?
I run 4 separate threads this way, I have a watchdog that can call Start()
to restart the thread if need be - but this error occurs on first pass at startup.


   public  bool Start()
        {
            bool bRet = false;
            try
            {
                if (P.APPL.moThread == null)
                {
                    //start thread main, use bContinue semaphore to stop it
                    P.APPL.moThreadMain = new ThreadStart(Do);
                    P.APPL.moThread = new Thread(P.APPL.moThreadMain);
                    Thread.Sleep(1000);
                }

                if (!P.APPL.moThread.IsAlive)            <<<<<< Thread.IsAlive is False
                {
                    P.APPL.moThread.Start();            <<<<<<< Exception generated here
                }
                bRet = true;
            }
            catch (Exception Ex)
            {
                DBG.Print("A.Start(), Ex=" + Ex.ToString());
            }
            return bRet;
        }


#2

The problem is the thread actually starts, ans IsAlive goes True!


#3

The code you are showing has nothing to do with the Instantiation of a FileStream object, which the stack trace and exception indicate. The exception is telling you the file does not exist.


#4

Ahhh, problem must be in the thread that was started! Thanks Mike