コード例 #1
0
        /// <summary>
        /// FUNCTION: Close
        /// PURPOSE : To close a session
        /// </summary>
        public bool Close()
        {
            bool Success = false; // init success to failure

            try
            {
                SNMPAPI_STATUS Result = new SNMPAPI_STATUS(); // set up a result item

                // close the session
                Result = SnmpAPI.SnmpClose(Session);
                if (Result != SNMPAPI_STATUS.SNMPAPI_SUCCESS)
                {
                    throw new Exception("SNMP Close Error");
                }

                // call clean up for garbage collection
                Result = SnmpAPI.SnmpCleanup();
                if (Result != SNMPAPI_STATUS.SNMPAPI_SUCCESS)
                {
                    throw new Exception("SNMP Ternination Error");
                }

                Success = true;
            }
            catch (Exception Err)
            {
                ErrMess = Err.Message;
            }
            return(Success); // return success flag
        }