Пример #1
0
        /// <summary>
        /// Pause the capturing.
        /// </summary>
        /// <param name="adapterIndex"></param>
        /// <returns></returns>
        public bool PauseCapture(List <uint> adapters)
        {
            uint errno;

            try
            {
                foreach (uint adapterIndex in adapters)
                {
                    errno = NetmonAPI.NmPauseCapture(this.captureEngineHandle, adapterIndex);
                    if (errno != 0)
                    {
                        throw new Exception(FormatErrMsg("NmPauseCapture() failed", errno));
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                NetmonAPI.NmCloseHandle(this.captureEngineHandle);
                NetmonAPI.NmCloseHandle(this.captureFileHandle);
                this.captureEngineHandle = IntPtr.Zero;
                this.captureFileHandle   = IntPtr.Zero;

                ErrorMsg += ex.ToString();

                return(false);
            }
        }