示例#1
0
        public static void Test_Abort_01()
        {
            _tr.WriteLine("Test_Abort_01");
            _tr.WriteLine("execute endless loop");
            int i = 0;

            while (true)
            {
                _tr.Write(".");
                if (i++ == 100)
                {
                    i = 0;
                    _tr.WriteLine();
                }
                Thread.Sleep(100);
                if (_rs.IsExecutionAborted())
                {
                    break;
                }
            }
        }
示例#2
0
        public static void Test_FileSystemWatcher_01()
        {
            string path   = @"c:\Users\Pierre\AppData\Local\Temp";
            string filter = "*.cmdline";

            _tr.WriteLine("Test_FileSystemWatcher_01 \"{0}\" \"{1}\"", path, filter);
            FileSystemWatcher watcher = new FileSystemWatcher(path);

            watcher.Filter       = filter;
            watcher.NotifyFilter = NotifyFilters.Attributes | NotifyFilters.CreationTime | NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.Security | NotifyFilters.Size;
            watcher.Changed     += new FileSystemEventHandler(watcher_Changed);
            watcher.Created     += new FileSystemEventHandler(watcher_Changed);
            watcher.Deleted     += new FileSystemEventHandler(watcher_Changed);
            watcher.Renamed     += new RenamedEventHandler(watcher_Renamed);

            try
            {
                watcher.EnableRaisingEvents = true;
                while (true)
                {
                    //if (_wr.Abort)
                    if (_wr.IsExecutionAborted())
                    {
                        break;
                    }
                }
            }
            finally
            {
                watcher.EnableRaisingEvents = false;
                watcher.Dispose();
                if (__fs != null)
                {
                    __fs.Close();
                    __fs = null;
                }
            }
        }