using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

using System.Security.Permissions;

namespace ThreadLibrary
{
   public class Tasks
   {
      public void Action1()
      {
         try
         {
            for (;;)
            {
               Thread.Sleep(500);
               Console.WriteLine("Action1: " + Thread.CurrentThread.Name);
            }
         }
         catch (ThreadAbortException ex)
         {
            Console.WriteLine(ex.Message);
            Thread.ResetAbort();
         }
         finally
         {
            Console.WriteLine("Thread sauber beenden");
         }

         //Code, nachdem Thread.Abort aufgehoben wurde
         Console.WriteLine("Thread - ist noch akiv.");
         for (; ; )
         {
            Thread.Sleep(500);
            Console.WriteLine("(noch akiv) Action1: " + Thread.CurrentThread.Name);
         }
      }

      public void Action2(object p)
      {
         for (;;)
         {
            Thread.Sleep(1000);
            Console.WriteLine("Action2: " + Thread.CurrentThread.Name);
         }
      }
   }
}
