예제 #1
0
        /// <summary>
        /// Called when [stop process watcher].
        /// </summary>
        /// <returns>OnStopUSBWatcherResponse object.if successful un init object mUSBw of _m_USB_Watcher and then stop it and return "USBWatcherStoped" message if the process watcher is already stoped return "USBWatcherStopedBefore" message else return error</returns>
        public static OnStopUSBWatcherResponse OnStopUSBWatcher()
        {
            OnStopUSBWatcherResponse ROnStopUSBWatcherResponse = new OnStopUSBWatcherResponse();

            try
            {
                if (mUSBw != null)
                {
                    mUSBw.keepRunning = false;
                    mUSBw             = null;
                    ROnStopUSBWatcherResponse.Description = "USBWatcherStoped";
                }
                else
                {
                    ROnStopUSBWatcherResponse.Description = "USBWatcherStopedBefore";
                }
            }
            catch (Exception ex)
            {
                ROnStopUSBWatcherResponse.Errors.AddErrorToErrorList(MethodBase.GetCurrentMethod().ToString(), ex.Message);
            }
            return(ROnStopUSBWatcherResponse);
        }
예제 #2
0
        /// <summary>
        /// Called when [start usb watcher].
        /// </summary>
        /// <returns>OnStartUSBWatcherResponse object.if successful init object mUSBw of _m_USB_Watcher and then start it and return "USBWatcherStarted" message if the usb watcher is already running return "USBWatcherStartedBefore" message else return error</returns>
        public static OnStartUSBWatcherResponse OnStartUSBWatcher()
        {
            OnStartUSBWatcherResponse ROnStartUSBWatcherResponse = new OnStartUSBWatcherResponse();

            try
            {
                if (mUSBw == null)
                {
                    mUSBw = new _m_USB_Watcher();
                    Thread USBWatcherThread = new Thread(new ThreadStart(mUSBw.StartWatching));
                    USBWatcherThread.Start();
                    ROnStartUSBWatcherResponse.Description = "USBWatcherStarted";
                }
                else
                {
                    ROnStartUSBWatcherResponse.Description = "USBWatcherStartedBefore";
                }
            }
            catch (Exception ex)
            {
                ROnStartUSBWatcherResponse.Errors.AddErrorToErrorList(MethodBase.GetCurrentMethod().ToString(), ex.Message);
            }
            return(ROnStartUSBWatcherResponse);
        }