public ClientForm(IList <IExecutionItemList> executionItemListList) { InitializeComponent(); IEnumerable <TreeNode> treeNodes = from executionItemList in executionItemListList orderby executionItemList.ToString() select BuildTreeNode(executionItemList); tvExecutionList.Nodes.AddRange(treeNodes.ToArray()); TextWriter textWriter = new RichTextBoxWriter(tbConsole); TextWriter compsoiteWriter = new CompositeTextWriter(Console.Out, textWriter); Console.SetOut(compsoiteWriter); }
public LogViewer() { InitializeComponent(); TextBoxWriter = new RichTextBoxWriter(logTextBox); }
internal static void RunCode(AppDomain playerAppDomain, PlayerData currentPlayerData, RichTextBoxWriter playerConsoleStream) { try { var proxy = (ServiceProxy)playerAppDomain.CreateInstanceFromAndUnwrap("SystemDll.dll", "SystemDll.ServiceProxy"); var thread = new Thread(() => { proxy.StartInstance(currentPlayerData, playerConsoleStream); }) { IsBackground = true }; thread.SetApartmentState(ApartmentState.STA); var initialTime = playerAppDomain.MonitoringTotalProcessorTime; long initialMemory = playerAppDomain.MonitoringTotalAllocatedMemorySize; thread.Start(); while (thread.IsAlive) { Thread.Yield(); if ((playerAppDomain.MonitoringTotalAllocatedMemorySize - initialMemory > MAX_MEMORY) || (playerAppDomain.MonitoringTotalProcessorTime - initialTime).Ticks > MAX_PROCESSING_SPAN) { thread.Abort(); break; } } var memoryUsed = playerAppDomain.MonitoringTotalAllocatedMemorySize - initialMemory; var secondsUsed = (playerAppDomain.MonitoringTotalProcessorTime - initialTime).Ticks / TICKS_IN_MILLISECOND / 1000d; Console.WriteLine($"Ending with {FormatBytes(memoryUsed)} of memory used, in {secondsUsed:0.000} seconds"); } catch (Exception e) { Console.WriteLine(e.ToString()); } }