当前位置: 首页>>代码示例>>C#>>正文


C# Watcher类代码示例

本文整理汇总了C#中Watcher的典型用法代码示例。如果您正苦于以下问题:C# Watcher类的具体用法?C# Watcher怎么用?C# Watcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Watcher类属于命名空间,在下文中一共展示了Watcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnStart

        protected override void OnStart(string[] args)
        {
            try
            {
                Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);

                var configuration = Settings.LoadSettings();

                watcher = new Watcher(configuration);
                watcher.Start();
                log.Info("FileSystemWatcher started");

                poster = new AutoPoster(configuration);
                poster.Start();
                log.Info("Autoposter started");

                notifier = new IndexerNotifier(configuration);
                notifier.Start();
                log.Info("Notifier started");

                verifier = new IndexerVerifier(configuration);
                verifier.Start();
                log.Info("Verifier started");

            }
            catch (Exception ex)
            {
                log.Fatal("Fatal exception when starting the autoposter.", ex);
                throw;
            }
        }
开发者ID:jonnyboy,项目名称:nntpPoster,代码行数:31,代码来源:Service.cs

示例2: Main

        static void Main(string[] args)
        {
            var watcher = new Watcher(@"d:\Учеба\3 сем. Assembler, AutoCad, C#, MatLab\C#\Lab_3.Shabanski\",
                                      @"d:\Учеба\3 сем. Assembler, AutoCad, C#, MatLab\C#\Lab_3.Shabanski\out_file.txt");
            watcher.Start();

            var faculty = TestCreateFaculty("Faculty of Computer Systems and Networks");
            foreach (var group in faculty)
                Console.WriteLine(group.ToString());
            using (var file = new FileStream(@"d:\Учеба\3 сем. Assembler, AutoCad, C#, MatLab\C#\Lab_3.Shabanski\data.bin", FileMode.OpenOrCreate))
            {
                using(var file_deflate = new DeflateStream(file, CompressionMode.Compress))
                {
                    faculty.SaveBinaryToStream(file_deflate);
                }
            }
            Console.ReadKey();

            Faculty f1;
            using (var file = new FileStream(@"d:\Учеба\3 сем. Assembler, AutoCad, C#, MatLab\C#\Lab_3.Shabanski\data.bin", FileMode.OpenOrCreate))
            {
                using (var file_deflate = new DeflateStream(file, CompressionMode.Decompress))
                {
                    f1 = Faculty.LoadBinaryFromStream(file_deflate);
                }
            }

            foreach (var group in faculty)
                Console.WriteLine(group.ToString());
            Console.ReadKey();
            watcher.Stop();
        }
开发者ID:Raumo0,项目名称:Labs,代码行数:32,代码来源:Program.cs

示例3: Create

 public static int Create(ManagedDirectory info)
 {
     var gen = new Watcher(info);
     gen.Index = __watchers.Count;
     __watchers.Add(gen);
     return gen.Index;
 }
开发者ID:RyuaNerin,项目名称:SQUI,代码行数:7,代码来源:Watcher.cs

示例4: OnMouseUp

    public void OnMouseUp()
    {
        GUI_TextureFactory.PaintPercentBar( tex, rand * 100 );

        Process p;

        p = PDelay( .5f );

        p.Enqueue( PDelay( .5f ) )
            .Enqueue( PDelay( .1f ) )
            .Enqueue( PDelay( .1f ) )
            .Enqueue( PDelay( .1f ) )
            .Enqueue( PDelay( .1f ) )
            .Enqueue( PDelay( .1f ) )
            .Enqueue( PDelay( .1f ) )
            .Enqueue( PDelay( .1f ) )
            .Enqueue( PDelay( .1f ) ).Enqueue( PDelay( 50 ) ).Attach( PDelay( .25f ) );

        pm.Add( p );

        Watcher<ProcessBook.Wait> w = new Watcher<ProcessBook.Wait>();

        w.eventWillStart += delegate( Process p1 ) {
            Process p2 = PDelay( 50 );
            p2.Attach( PDelay( 50 ) ).Attach( PDelay( 50 ) ).Attach( PDelay( 50 ) );
            p2.Enqueue( PDelay( 50 ) ).Enqueue( PDelay( 50 ) ).Enqueue( PDelay( 50 ) );
            pm.OvertakeAdd( p2, p1 );
            Debug.LogWarning( "BAZINGA! >> " + p1 );
        };

        pm.Add( w );
    }
开发者ID:choephix,项目名称:G11,代码行数:32,代码来源:TestBehaviour.cs

示例5: ShouldWriteInitialTail

        public void ShouldWriteInitialTail()
        {
            const int LogFileLineCount = 9;

            var filePath = logFile9;
            using (var watcher = new Watcher())
            {
                string[] writtenLines;
                using (var stringWriter = new StringWriter())
                {
                    var writer = new LineTextWriter(stringWriter);
                    watcher.LineWriter = writer;
                    watcher.DirectoryPath = Path.GetDirectoryName(filePath);
                    watcher.Filter = Path.GetFileName(filePath);
                    watcher.LineCount = 4;
                    watcher.Start();
                    writer.Flush();
                    Thread.Sleep(200);
                    writtenLines = stringWriter.ToString().ToLines();
                }
                writtenLines.ForEach(i => Debug.WriteLine(i));

                var expectedLines = CreateLineListWithFileMarker(
                    TestData.LoadLines(logFile9,
                                       LogFileLineCount - watcher.LineCount,
                                       watcher.LineCount));
                CompareLines(expectedLines.ToArray(), writtenLines);
            }
        }
开发者ID:helgihaf,项目名称:Grocker,代码行数:29,代码来源:WatcherTests.cs

示例6: FileSystemWatcherService

 public FileSystemWatcherService(string path)
 {
     // This call is required by the Windows.Forms Component Designer.
     InitializeComponent();
     _builder = new StringBuilder();
     _writer = new StringWriter(_builder);
     _fileSystemWatcher = new Watcher(path, "", _writer);
 }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:8,代码来源:FileSystemWatcherService.cs

示例7: Game

			public Game() {
				manager = new Manager();
				watcher = new Watcher(manager);
				instance = new Instance();
				save = new Save();
				env = new Environments();
				env.GUID = Guid.NewGuid();
			}
开发者ID:Ghost53574,项目名称:CSdk,代码行数:8,代码来源:Game.cs

示例8: BaseZkTest

 protected BaseZkTest(string zkConnectionString,
                         int sessionTimeout,
                         Watcher watcher,
                         bool readOnly)
 {
     ZkConnectionString = zkConnectionString;
     Zookeeper = new ZooKeeper(zkConnectionString, sessionTimeout, watcher, readOnly);
 }
开发者ID:Lagrang,项目名称:CuratorNet,代码行数:8,代码来源:BaseZkTest.cs

示例9: Main

        public static void Main(string[] args)
        {
            var arguments = new List<string>();

            arguments.AddRange(args);

            var configuration = GetConfigurationFromArguments(arguments);

            if(configuration.Help)
                return;

            if (arguments.Count == 0)
            {
                WriteHelp();
                return;
            }

            var inputFile = new FileInfo(arguments[0]);

            if (!inputFile.Exists && inputFile.Extension != ".less" && !inputFile.FullName.EndsWith(".less.css"))
                inputFile = new FileInfo(inputFile.FullName + ".less");

            string outputFilePath;
            if (arguments.Count > 1)
            {
                outputFilePath = arguments[1] + (Path.HasExtension(arguments[1]) ? "" : ".css");
                outputFilePath = Path.GetFullPath(outputFilePath);
            }
            else if (inputFile.FullName.EndsWith(".less.css"))
                outputFilePath = inputFile.Name.Substring(0, inputFile.Name.Length - 9) + ".css";
            else
                outputFilePath = Path.ChangeExtension(inputFile.Name, ".css");

            var currentDir = Directory.GetCurrentDirectory();
            if (inputFile.Directory != null)
                Directory.SetCurrentDirectory(inputFile.Directory.FullName);

            var engine = new EngineFactory(configuration).GetEngine();
            Func<IEnumerable<string>> compilationDelegate = () => Compile(engine, inputFile.Name, outputFilePath);

            var files = compilationDelegate();

            if (configuration.Watch)
            {
                WriteAbortInstructions();

                var watcher = new Watcher(files, compilationDelegate);

                while (Console.ReadLine() != "")
                {
                    WriteAbortInstructions();
                }

                watcher.RemoveWatchers();
            }

            Directory.SetCurrentDirectory(currentDir);
        }
开发者ID:ayoung,项目名称:dotless,代码行数:58,代码来源:Program.cs

示例10: HandleHolder

 internal HandleHolder(ZookeeperFactory zookeeperFactory, Watcher watcher, EnsembleProvider ensembleProvider,
     int sessionTimeout, bool canBeReadOnly)
 {
     this.zookeeperFactory = zookeeperFactory;
     this.watcher = watcher;
     this.ensembleProvider = ensembleProvider;
     this.sessionTimeout = sessionTimeout;
     this.canBeReadOnly = canBeReadOnly;
 }
开发者ID:shayhatsor,项目名称:curator,代码行数:9,代码来源:HandleHolder.cs

示例11: Main

        static void Main(string[] args)
        {
            try
            {
                var configuration = Settings.LoadSettings();

                Watcher watcher = new Watcher(configuration);
                watcher.Start();
                log.Info("FileSystemWatcher started");
                Console.WriteLine("FileSystemWatcher started");

                AutoPoster poster = new AutoPoster(configuration);
                poster.Start();
                log.Info("Autoposter started");
                Console.WriteLine("Autoposter started");

                IndexerNotifier notifier = new IndexerNotifier(configuration);
                notifier.Start();
                log.Info("Notifier started");
                Console.WriteLine("Notifier started");

                IndexerVerifier verifier = new IndexerVerifier(configuration);
                verifier.Start();
                log.Info("Verifier started");
                Console.WriteLine("Verifier started");

                Console.WriteLine("Press the \"s\" key to stop after the current operations have finished.");

                Boolean stop = false;
                while (!stop)
                {
                    var keyInfo = Console.ReadKey();
                    stop = keyInfo.KeyChar == 's' || keyInfo.KeyChar == 'S';
                }

                watcher.Stop();
                log.Info("FileSystemWatcher stopped");
                Console.WriteLine("FileSystemWatcher stopped");

                verifier.Stop();
                log.Info("Verifier stopped");
                Console.WriteLine("Verifier stopped");

                notifier.Stop();
                log.Info("Notifier stopped");
                Console.WriteLine("Notifier stopped");

                poster.Stop();
                log.Info("Autoposter stopped");
                Console.WriteLine("Autoposter stopped");
            }
            catch(Exception ex)
            {
                log.Fatal("Fatal exception when starting the autoposter.", ex);
                throw;
            }
        }
开发者ID:jonnyboy,项目名称:nntpPoster,代码行数:57,代码来源:Program.cs

示例12: WatcherApplicationContext

        public WatcherApplicationContext()
        {
            InitializeContext();

            _watcher = new Watcher()
                           {
                               EventTriggered = WatcherTriggered
                           };
            _watcher.Start();
        }
开发者ID:kal444,项目名称:event-log-watcher,代码行数:10,代码来源:WatcherApplicationContext.cs

示例13: CreateWatcherWithOptions

        private static Watcher CreateWatcherWithOptions(Options options)
        {
            var watcher = new Watcher();

            watcher.DirectoryPath = options.DirectoryPath ?? Environment.CurrentDirectory;
            watcher.Filter = options.Filter ?? "*.log";
            watcher.LineWriter = CreateWriter(options);

            return watcher;
        }
开发者ID:helgihaf,项目名称:Grocker,代码行数:10,代码来源:Program.cs

示例14: BootStrapper

 public BootStrapper( DaemonConfiguration configuration, IBus bus, Watcher minionWatcher )
 {
     Configuration = configuration.BootStrapConfiguration;
     Bus = bus;
     MinionWatcher = minionWatcher;
     bus.AddLocalChannel( x => x
                         .CorrelateBy<NewApplication>( m => m.DirectoryPath )
                         .CorrelateBy<ApplicationChanged>( m => m.DirectoryPath )
                         .CorrelateBy<ApplicationDeleted>( m => m.DirectoryPath ) );
 }
开发者ID:cmgator,项目名称:Symbiote,代码行数:10,代码来源:BootStrapper.cs

示例15: start

 private void start()
 {
     _watcher = new Watcher(
         _watchPath,
         (dir) => WatcherChangeHandler(ChangeType.DirectoryCreated, dir),
         (dir) => WatcherChangeHandler(ChangeType.DirectoryDeleted, dir),
         (file) => WatcherChangeHandler(ChangeType.FileCreated, file),
         (file) => WatcherChangeHandler(ChangeType.FileChanged, file),
         (file) => WatcherChangeHandler(ChangeType.FileDeleted, file));
     _watcher.Watch();
 }
开发者ID:JamesTryand,项目名称:OpenIDE,代码行数:11,代码来源:FileChangeTracker.cs


注:本文中的Watcher类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。