Exemplo n.º 1
0
        public async Task <bool> StopAsync(CancellationToken cancellationToken)
        {
            if (JobStatus == JobStatus.Running || JobStatus == JobStatus.Paused)
            {
                JobStoppingTask = Task.Run(() =>
                {
                    JobLoadCancellationTokenSource.Cancel();
                    JobAssembly.Instance.StopAsync(JobUnloadCancellationTokenSource.Token);
                }, cancellationToken).ContinueWith((task) =>
                {
                    JobStatus = JobStatus.Stopped;
                });

                JobStatus = JobStatus.Stopping;

                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        private void WatchJob()
        {
            _fileSystemWatcher = new FileSystemWatcher
            {
                Filter = Path.GetFileName(JobAssembly.JobFullPath),
                Path   = Path.GetDirectoryName(JobAssembly.JobFullPath),
                IncludeSubdirectories = false,
                EnableRaisingEvents   = true
            };

            _fileSystemWatcher.Changed += (sender, args) =>
            {
                if (UpdatingMode)
                {
                    return;
                }

                UpdatingMode = true;

                JobLoadCancellationTokenSource.Cancel();
            };
        }