2
我想運行一個可執行文件並限制它的內存和時間使用。當然 我想知道它是否違反了任何這些事情,如果不是,我想要 數據使用了多少。我可以從.NET使用什麼來做到這一點?如何運行帶有時間和內存使用限制的可執行文件?
我想運行一個可執行文件並限制它的內存和時間使用。當然 我想知道它是否違反了任何這些事情,如果不是,我想要 數據使用了多少。我可以從.NET使用什麼來做到這一點?如何運行帶有時間和內存使用限制的可執行文件?
您可以使用線程來監視您運行的可執行文件。
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
祝你好運。
這不是一個編程問題,即使您可能想要這樣做是因爲編程問題。我建議將其移至ServerFault。 –
我不同意,他想創建一個程序來監視可執行文件 - 不使用開箱即用的監視應用程序。 –