0

I am using a thread in my ASP.Net application to be run in the backGround every 2 hours, using C# See code below, but my question is how can I know if this specific thread is still running on the server ?? Note: I am using Windows server 2008 R2 Standard note : but I wanna check i on the server because it is a production server. Windows 8 R2 Standard

 // Create runner Thread and start it 
     System.Threading.Thread OrderStatusFromThread = new       System.Threading.Thread(new System.Threading.ThreadStart(OrderStatusChange));
        OrderStatusFromThread.IsBackground = true;
        OrderStatusFromThread.Name = "OrderStatusFromThread";
        OrderStatusFromThread.Start();
    }

   static void OrderStatusChange()
    {
        while (!ShutDown)
        {
          System.Threading.Thread.Sleep((1000 * 60)*10);               
          UpdateOrderStatusFromAPI();         
        }
    }
  • You may want to consider running your code as a service then the standard service management tools will show you its state. Also look at scheduled tasks, these have history and will note if the process failed. – rob Jul 07 '14 at 09:45

1 Answers1

0

Use Thread.isAlive to determine f thread is running. You can get the syntax from http://msdn.microsoft.com/en-us/library/system.threading.thread.isalive%28v=vs.110%29.aspx

  • I'm trying to find a tool similar to the Windows Task Manager utility which can show details on all threads running in a given process, such as their names, IDs, etc ..., I wanna check i on the server because it is a production server. – Mohamad Mahmoud Darwish Jul 07 '14 at 08:28