private void Exec(object param) { var out_stream = new MemoryStreamWithNotifications(); out_stream.Writed += out_stream_Writed; out_stream.WriteUTF8("[INFO] Starting...\r\n"); var start = DateTime.Now; try { // This is fast var compiler = MtCompiler.CreateScriptApp(out_stream); // This may take a while var res = compiler.Evaluate(param as string); if (res == null) { throw new Exception("Evaluation returned null. WTF!?"); } // This may take a LONG time res.WaitForValue(); var dur = DateTime.Now - start; out_stream.WriteUTF8("[INFO] Completed in {0} seconds.\r\n".ExtFormat(dur.TotalSeconds)); } catch (ThreadAbortException) { var dur = DateTime.Now - start; out_stream.WriteUTF8("[ABORTED] After {0} seconds.\r\n".ExtFormat(dur.TotalSeconds)); } catch (Exception ex) { out_stream.WriteUTF8("[ERROR] Exception executing script {0}.\r\n".ExtFormat(ex.Message)); } finally { Done(); } }
private void Exec(object param) { var out_stream = new MemoryStreamWithNotifications(); out_stream.Writed += out_stream_Writed; out_stream.WriteUTF8("[INFO] Starting...\r\n"); var start = DateTime.Now; try { // This is fast var compiler = MtCompiler.CreateScriptApp(out_stream); // This may take a while var res = compiler.Evaluate(param as string); if (res == null) { throw new Exception("Evaluation returned null. WTF!?"); } // This may take a LONG time res.WaitForValue(); var dur = DateTime.Now - start; out_stream.WriteUTF8("[INFO] Completed in {0} seconds.\r\n".ExtFormat(dur.TotalSeconds)); } catch (ThreadAbortException) { var dur = DateTime.Now - start; out_stream.WriteUTF8("[ABORTED] After {0} seconds.\r\n".ExtFormat(dur.TotalSeconds)); } catch (Exception ex) { out_stream.WriteUTF8("[ERROR] Exception executing script {0}.\r\n".ExtFormat(ex.Message)); } finally { Done(); } }