示例#1
0
 public async Task RunAsync(CompiledCode compiledCode)
 {
     try
     {
         using (var consoleInStream = new BlockingMemoryStream())
             using (consoleInWriter = TextWriter.Synchronized(new StreamWriter(consoleInStream)))
                 using (var consoleInReader = TextReader.Synchronized(new StreamReader(consoleInStream)))
                 {
                     await RunAsync(compiledCode, consoleInReader);
                 }
     }
     finally
     {
         consoleInWriter = null;
     }
 }
示例#2
0
 public async Task RunAsync(CompiledCode compiledCode, TextReader consoleInTextReader)
 {
     try
     {
         var sandboxMgr = new SandboxManager();
         sandboxMgr.ConsoleWrite += OnConsoleWrite;
         await Task.Run(() =>
                        sandboxMgr.RunInSandbox(compiledCode.bin, compiledCode.pdb, consoleInTextReader)
                        );
     }
     catch (Exception e) when(!(e is AggregateException))
     {
         if (exceptionLogger != null)
         {
             await exceptionLogger.LogException(e, compiledCode.source);
         }
         throw;
     }
 }