Esempio n. 1
0
        public iMiror(MiirorItem mi)
        {
            MirorItem = mi;

            if (0 < mi.Filtered.Length)
            {
                if (mi.Filtered.StartsWith("~"))
                {
                    FilterList.AddRange(mi.Filtered.Substring(1).Split('|'));
                }
                else
                {
                    ReserveList.AddRange(mi.Filtered.Split('|'));
                }
            }

            try
            {
                fsm = FileScanManager.GetInstance(mi);
                fsm.FilterList = FilterList;
                fsm.ReserveList = ReserveList;
                if (mi.IsWorking)
                {
                    DoLooseScan();
                    SystemWatch(true);
                }
            }
            catch (IOException IOex)
            {
                Log.GetInstance().WriteLog(IOex.Message);
                Stop();
            }
            catch (Exception ex)
            {
                Log.GetInstance().WriteLog(ex.Message);
            }
            finally
            {
                timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
                timer.Interval = WATCH_SPAN;
                if (mi.IsWorking)
                {
                    timer.Enabled = true;
                    timer.Start();
                }
            }
        }
Esempio n. 2
0
        public void Dispose()
        {
            fsw.Changed -= new FileSystemEventHandler(fsw_Changed);
            fsw.Created -= new FileSystemEventHandler(fsw_Changed);
            fsw.Deleted -= new FileSystemEventHandler(fsw_Changed);
            fsw.Renamed -= new RenamedEventHandler(fsw_Renamed);
            fsw.Error -= new ErrorEventHandler(fsw_Error);
            fsw.Dispose();
            fsw = null;

            fsm = null;

            timer.Stop();
            timer.Enabled = false;
            timer.Elapsed -= new ElapsedEventHandler(timer_Elapsed);
            timer.Dispose();
            timer = null;

            fileStack = null;
        }