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();         
        }
    }
1
  • 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 7, 2014 at 9:45

1 Answer 1

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

1
  • 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. Jul 7, 2014 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.