При выполнении Процесса. Запустите (), необходимо ли обернуть его в использование?

Student** db = new Student*[5];
// To allocate it statically:
Student* db[5];
9
задан Simon 4 November 2009 в 06:13
поделиться

2 ответа

Looking at the implementation of the Process.dispose(bool) method shows that it calls Close() on the Process instance. This in turn cleans up the native process handle so its probably not a bad idea.

It also cleans up a wait handle that it uses to check if the process has exited.

Even if you don't use the using (...) block the finalizer will catch these resources in the end.

6
ответ дан 4 December 2019 в 21:50
поделиться

The Process object that is returned by Process.Start contains a Windows process HANDLE, so it should be disposed once you no longer need to use the Process object.

If you don't need to use the returned Process object at all, then the empty using block that you show is fine. Note that disposing the Process releases the handle but it (fortunately) does not stop the process from executing.

3
ответ дан 4 December 2019 в 21:50
поделиться
Другие вопросы по тегам:

Похожие вопросы: