예제 #1
0
 void Abortee5( )
 {
     try                            { int a = gNum / gDenom; }
     catch (ArithmeticException) {
         Console.WriteLine("__05:Got arithmetic exception");
         try {
             AbortStart.Set( );
             Console.WriteLine("__05:waiting for someone to abort");
             AbortSent.WaitOne( );
             Console.WriteLine("__05:waiting some more to make sure we are not interrupted");
             for (int i = 0; i < 3; i++)
             {
                 Delay(5000);
                 Console.Write("5");
             }
             Console.WriteLine( );
             Console.WriteLine("__05:Done");
         }
         catch (Exception) {
             Console.WriteLine("__05:Should get here");
         }
         Console.WriteLine("__05:ResetingAbort to defeat the abort");
         Thread.ResetAbort( );
     }
     Console.WriteLine("__05:Should see this after calling Thread.ResetAbort( )");
 }
예제 #2
0
 void Abortee6( )
 {
     try                            { int a = gNum / gDenom; }
     catch (ArithmeticException) {
         Console.WriteLine("__06:Got arithmetic exception");
         try {
             AbortStart.Set( );
             Console.WriteLine("__06:waiting for someone to abort");
             AbortSent.WaitOne( );
             Console.WriteLine("__06:waiting some more to make sure we are not interrupted");
             for (int i = 0; i < 3; i++)
             {
                 Delay(1000);
                 Console.Write("6");
             }
             Console.WriteLine( );
             Console.WriteLine("__06:Done");
         }
         catch (ArithmeticException) {
             Console.WriteLine("%_06:Should not get here");
             retCode = 6;
         }
     }
     Console.WriteLine("%_06:Should not see this ");
     retCode = 6;
 }
예제 #3
0
    public static void Aborter2(ThreadStart abortee)
    {
        Thread t = new Thread(abortee);

        t.Start( );
        AbortStart.WaitOne( );
        Console.WriteLine("A__2:Aborting t1");
        t.Abort(t);
        t.Abort(t);
        t.Abort(t);
        AbortSent.Set( );
        t.Join( );
        Console.WriteLine("A__2:Test passed");
        Console.WriteLine("    :***********************************");
    }