c# - 如何在时间和内存使用限制的情况下运行可执行文件?

标签 c#

我想运行一个可执行文件并限制其内存和时间使用。当然 我想知道它是否违反了这些规定,如果没有,我想要 数据使用了多少。我可以使用 .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

祝你好运。

关于c# - 如何在时间和内存使用限制的情况下运行可执行文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1381275/

相关文章:

c# - LINQ Take()一遍又一遍地返回相同的结果

c# - 如何在Azure Function的HttpTrigger中使用Authorize属性

c# - 为什么List<>实现了RemoveAll,而IList<>却没有

c# - 从代码后面的输入框获取值

c# - 如何在自己的方法中模仿string.Format()?

c# - XAML Windows 通用应用程序的全局命令栏

c# - 为了我们可以在其上放置 foreach,对集合的要求是什么?

c# - 母版页值中的下拉列表在新选择后未更新

c# - 在 Featureset Dotspatial 中设置字段值

c# - 检查微软组件是否存在