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

syn*_*pis 2 c#

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

Era*_*lel 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
Run Code Online (Sandbox Code Playgroud)

祝好运.