如何运行具有时间和内存使用限制的可执行文件?

时间:2009-09-04 20:00:23

标签: c#

我想运行可执行文件并限制其内存和时间使用。当然 我想知道它是否违反了这些东西,如果不是我想要的话 数据使用了多少。我可以从.NET中使用什么来做到这一点?

1 个答案:

答案 0 :(得分:5)

您可以使用线程来监控您运行的可执行文件。

var process = Process.Start("Test.exe");

//  Monitor - Use this property to monitor the memory
process.MainModule.ModuleMemorySize

//  Monitor - Use this property to monitor the time
process.StartTime

//  Limit - You can use this property to limit the executable memory size,
//  but I wouldn't recommend it...
process.MaxWorkingSet

祝你好运。

相关问题