首页 > 解决方案 > c# 中的 Process 类是非托管资源吗?

问题描述

this.proc - 是Process[].

我应该在“释放你自己的状态(非托管对象)”块中写任何东西来释放Process[]吗?

protected virtual void Dispose(bool disposing)
{
    if (!_disposed)
    {
        if (disposing)
        {
            foreach (var i in this.proc)
            {
                i?.Dispose();
            }
        }

        // Free your own state (unmanaged objects).
        // Set large fields to null.
        _disposed = true;
    }
}

标签: c#idisposable

解决方案


推荐阅读