简体   繁体   English

如何释放进程的资源

[英]how to release resources of a process

I am invoking an external process by using System.Diagonistics.Process and passing two filenames as parameters.我通过使用 System.Diagonistics.Process 并传递两个文件名作为参数来调用外部进程。 Now some time this process terminates due to exceptions and it seems that files handle are not being released by the process.现在有一段时间这个进程由于异常而终止,并且进程似乎没有释放文件句柄。 How can i release the resources occupied by the process.如何释放进程占用的资源。

What is making you think that file handles are not being released?是什么让您认为文件句柄没有被释放? Since you are starting a process which is external to your application you don't have much control over what the other process is going to do when it terminates abnormally.由于您正在启动一个位于应用程序外部的进程,因此您无法控制其他进程在异常终止时将要执行的操作。

This application is WMVAppend.exe (available with Microsoft Media SDK).此应用程序是 WMVAppend.exe(可与 Microsoft Media SDK 一起使用)。 Even when we restart the machines, it report the error dialogue and work fine for the next run.即使我们重新启动机器,它也会报告错误对话框并在下次运行时正常工作。 The issue with only media appending which is not done by our process.我们的流程没有完成仅媒体附加的问题。 I also checked the source files and they seem perfect but they are not appended perfectly and files are not available to use.我还检查了源文件,它们看起来很完美,但它们没有完美地附加并且文件不可用。

Or It might be possible that process is not terminated at all, but i am using Process.WaitForExit() which should return only the process is terminated.或者进程可能根本没有终止,但我正在使用 Process.WaitForExit() 它应该只返回进程终止。 The error dialog on restart suggests me this case could be possible.重启时的错误对话框表明这种情况是可能的。

How are you detecting that file handles are not being released by the dying process?你如何检测文件句柄没有被死亡进程释放?

All resources should be released by a process that dies for any reason.所有资源都应该由因任何原因终止的进程释放。 If they aren't, then it is a bug that should be filed with Microsoft.如果不是,那么这是一个应该向 Microsoft 提交的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM