Click here to Skip to main content
15,885,869 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi friends... I have an application which involves multithreading.. I want to restart the thread if it crashes or hangs.. But one thread should not effect the other.. This is my piece of code... Please help...
C#
if (result == "Video" | result == "Audio")
                {                   
                    
                    System.Threading.ThreadStart thread1 = delegate
                    {
                         new Media(listCont, ref c, SID);
                    };
                    new System.Threading.Thread(thread1).Start();
                    //Thread thread = new Thread(() => new Media(listCont, ref c));
                    //thread.Start();
                   
                }
                else if (result == "Image")
                {
                    System.Threading.ThreadStart thread2 = delegate
                    {
                        new Images(listCont, ref c, SID);
                    };
                    new System.Threading.Thread(thread2).Start();
                    //Thread thread = new Thread(() => new Images(listCont, ref c));
                    //thread.Start();
                }
                else if (result == "Ticker")
                {
                    System.Threading.ThreadStart thread3 = delegate
                    {
                        new Ticker(listCont, ref c, SID);
                    };
                    new System.Threading.Thread(thread3).Start();   
                    //Thread thread = new Thread(() => new Ticker(listCont, ref c));
                    //thread.Start();
                }
                else
                {
                    System.Threading.ThreadStart thread4 = delegate
                    {
                        new List(listCont, ref c, SID);
                    };
                    new System.Threading.Thread(thread4).Start();  
                    //Thread thread = new Thread(() => new List(listCont, ref c));
                    //thread.Start();
                }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900