Example #1
0
        /// <summary>
        /// Free Managed Ressources. Typically by calling Dispose on them
        /// </summary>
        protected override void DisposeManagedRessources()
        {
            CoreUtilities.SafeDispose(ref this._ProcessID);
            CoreUtilities.SafeDispose(ref this._ProcessTask);

            base.DisposeManagedRessources();
        }
Example #2
0
        /// <summary>
        /// Safe Dispose
        /// </summary>
        /// <param name="pObject"></param>
        public static void SafeDispose <T>(ref T pObject) where T : class
        {
            if (pObject != null && !pObject.GetType().IsValueType)
            {
                if (pObject is IList)
                {
                    IList list = pObject as IList;

                    for (int i = 0; i < list.Count; i++)
                    {
                        var item = list[i];
                        CoreUtilities.SafeDispose(ref item);
                        list[i] = item;
                    }
                }

                else if (pObject is IDisposable)
                {
                    (pObject as IDisposable).Dispose();
                }

                pObject = null;
            }
        }