//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: private Thread runInSeparateThread(final ThrowingRunnable action)
        private Thread RunInSeparateThread(ThrowingRunnable action)
        {
            Thread thread = CreateActionThread(action);

            thread.Start();
            return(thread);
        }
Exemplo n.º 2
0
 public virtual void Execute(ThrowingRunnable throwingRunnable)
 {
     try
     {
         throwingRunnable.Run();
     }
     catch (Exception e)
     {
         _throwables.Add(e);
     }
 }
 private Thread CreateActionThread(ThrowingRunnable action)
 {
     return(new Thread(() =>
     {
         try
         {
             action.Run();
         }
         catch (IOException e)
         {
             throw new Exception(e);
         }
     }));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Convenience for wrapping contestants, especially for lambdas, which throws any sort of
 /// checked exception.
 /// </summary>
 /// <param name="runnable"> actual contestant. </param>
 /// <returns> contestant wrapped in a try-catch (and re-throw as unchecked exception). </returns>
 public static ThreadStart Throwing(ThrowingRunnable runnable)
 {
     return(() =>
     {
         try
         {
             runnable.Run();
         }
         catch (Exception e)
         {
             throw new Exception(e);
         }
     });
 }
Exemplo n.º 5
0
 private static void AssertThrows(Type exceptionClass, Matcher <string> message, ThrowingRunnable action)
 {
     try
     {
         action.Run();
         fail("Should have failed");
     }
     catch (Exception e)
     {
         assertTrue(exceptionClass.IsInstanceOfType(e));
         assertThat(e.Message, message);
     }
 }