Пример #1
0
 public DispatcherTimer(Dispatcher dispatcher, ITaskScheduler scheduler, TimeSpan interval, DispatcherPriority priority)
 {
     this.dispatcher = dispatcher;
     this.scheduler = scheduler;
     this.Interval = interval;
     this.Priority = priority;
 }
Пример #2
0
        public LogFileSearch(ITaskScheduler taskScheduler, ILogFile logFile, string searchTerm, TimeSpan maximumWaitTime)
        {
            if (taskScheduler == null)
                throw new ArgumentNullException("taskScheduler");
            if (logFile == null)
                throw new ArgumentNullException("logFile");
            if (string.IsNullOrEmpty(searchTerm))
                throw new ArgumentException("searchTerm may not be empty");

            _logFile = logFile;
            _filter = new SubstringFilter(searchTerm, true);
            _matches = new List<LogMatch>();
            _syncRoot = new object();
            _listeners = new LogFileSearchListenerCollection(this);
            _pendingModifications = new ConcurrentQueue<LogFileSection>();
            _scheduler = taskScheduler;

            const int maximumLineCount = 1000;
            _maximumWaitTime = maximumWaitTime;
            _logLinesBuffer = new LogLine[maximumLineCount];
            _matchesBuffer = new List<LogLineMatch>();
            _logFile.AddListener(this, _maximumWaitTime, maximumLineCount);

            _task = _scheduler.StartPeriodic(FilterAllPending,
                                             TimeSpan.FromMilliseconds(100),
                                             string.Format("Search {0}", logFile));
        }
        public DeploySchedulerAppDeploymentTask(
            IProjectInfoRepository projectInfoRepository,
            IEnvironmentInfoRepository environmentInfoRepository,
            IArtifactsRepository artifactsRepository,
            ITaskScheduler taskScheduler,
            IPasswordCollector passwordCollector,
            IDirectoryAdapter directoryAdapter,
            IFileAdapter fileAdapter,
            IZipFileAdapter zipFileAdapter)
            : base(projectInfoRepository, environmentInfoRepository)
        {
            Guard.NotNull(artifactsRepository, "artifactsRepository");
              Guard.NotNull(taskScheduler, "taskScheduler");
              Guard.NotNull(passwordCollector, "passwordCollector");
              Guard.NotNull(directoryAdapter, "directoryAdapter");
              Guard.NotNull(fileAdapter, "fileAdapter");
              Guard.NotNull(zipFileAdapter, "zipFileAdapter");

              _artifactsRepository = artifactsRepository;
              _taskScheduler = taskScheduler;
              _passwordCollector = passwordCollector;
              _directoryAdapter = directoryAdapter;
              _fileAdapter = fileAdapter;
              _zipFileAdapter = zipFileAdapter;
        }
        public SubscriberSendChannelBuilder(
            MessageSender messageSender, 
            MessageCacheFactory messageCacheFactory, 
            ISystemTime systemTime, 
            ITaskRepeater taskRepeater, 
            MessageAcknowledgementHandler acknowledgementHandler, 
            ISerialiser serialiser, 
            ITaskScheduler taskScheduler,
            SenderAuthenticationSessionAttacherFactory authenticationSessionAttacherFactory)
        {
            Contract.Requires(messageSender != null);
            Contract.Requires(messageCacheFactory != null);
            Contract.Requires(systemTime != null);
            Contract.Requires(taskRepeater != null);
            Contract.Requires(acknowledgementHandler != null);
            Contract.Requires(serialiser != null);
            Contract.Requires(taskScheduler != null);
            Contract.Requires(authenticationSessionAttacherFactory != null);

            this.messageSender = messageSender;
            this.messageCacheFactory = messageCacheFactory;
            this.systemTime = systemTime;
            this.taskRepeater = taskRepeater;
            this.acknowledgementHandler = acknowledgementHandler;
            this.serialiser = serialiser;
            this.taskScheduler = taskScheduler;
            this.authenticationSessionAttacherFactory = authenticationSessionAttacherFactory;
        }
Пример #5
0
 public SingleDataSource(ITaskScheduler taskScheduler, DataSource settings, TimeSpan maximumWaitTime)
     : base(taskScheduler, settings, maximumWaitTime)
 {
     var logFile = new LogFile(taskScheduler, settings.File);
     _unfilteredLogFile = logFile;
     CreateFilteredLogFile();
 }
        public ReplySendChannelBuilder(
            MessageSender messageSender,
            ISerialiser serialiser,
            ISystemTime systemTime,
            ITaskRepeater taskRepeater,
            MessageCacheFactory messageCacheFactory,
            MessageAcknowledgementHandler acknowledgementHandler,
            ITaskScheduler taskScheduler,
            ReplyAuthenticationSessionAttacherFactory authenticationSessionAttacherFactory,
            ReplyCorrelationLookup correlationLookup)
        {
            Contract.Requires(messageSender != null);
            Contract.Requires(serialiser != null);
            Contract.Requires(systemTime != null);
            Contract.Requires(taskRepeater != null);
            Contract.Requires(messageCacheFactory != null);
            Contract.Requires(acknowledgementHandler != null);
            Contract.Requires(taskScheduler != null);
            Contract.Requires(authenticationSessionAttacherFactory != null);
            Contract.Requires(correlationLookup != null);

            this.messageSender = messageSender;
            this.serialiser = serialiser;
            this.systemTime = systemTime;
            this.taskRepeater = taskRepeater;
            this.messageCacheFactory = messageCacheFactory;
            this.acknowledgementHandler = acknowledgementHandler;
            this.taskScheduler = taskScheduler;
            this.authenticationSessionAttacherFactory = authenticationSessionAttacherFactory;
            this.correlationLookup = correlationLookup;
        }
        public AuthenticationSessionExpirer(ISystemTime systemTime, ITaskScheduler taskScheduler)
        {
            Contract.Requires(systemTime != null);
            Contract.Requires(taskScheduler != null);

            this.systemTime = systemTime;
            this.taskScheduler = taskScheduler;
        }
Пример #8
0
 public PackageController(IPackageDownloadCountIncrementer packageDownloadCountIncrementer, IPackageFileGetter packageFileGetter,
     IRepository<PublishedPackage> publishedPackageRepository, ITaskScheduler taskScheduler)
 {
     _packageDownloadCountIncrementer = packageDownloadCountIncrementer;
     _packageFileGetter = packageFileGetter;
     _publishedPackageRepository = publishedPackageRepository;
     _taskScheduler = taskScheduler;
 }
Пример #9
0
 public static ITaskScheduler GetScheduler()
 {
     if (TaskSchedulerFactory._scheduler == null)
     {
         TaskSchedulerFactory._scheduler = DIContainer.Resolve<ITaskScheduler>();
     }
     return TaskSchedulerFactory._scheduler;
 }
Пример #10
0
        protected AbstractLogFile(ITaskScheduler scheduler)
        {
            if (scheduler == null)
                throw new ArgumentNullException("scheduler");

            _scheduler = scheduler;
            _cancellationTokenSource = new CancellationTokenSource();
            _listeners = new LogFileListenerCollection(this);
        }
        public ToggleSchedulerAppEnabledStep(ITaskScheduler taskScheduler, string machineName, string schedulerTaskName, bool enabled)
        {
            Guard.NotNull(taskScheduler, "taskScheduler");
              Guard.NotNullNorEmpty(machineName, "machineName");

              _taskScheduler = taskScheduler;
              _machineName = machineName;
              _schedulerTaskName = schedulerTaskName;
              _enabled = enabled;
        }
Пример #12
0
        /// <summary>
        /// Create a new TaskWorkItem for running the specified Task on the specified scheduler.
        /// </summary>
        /// <param name="sched">Scheduler to execute this Task action. A value of null means use the Orleans system scheduler.</param>
        /// <param name="t">Task to be performed</param>
        /// <param name="context">Execution context</param>
        internal TaskWorkItem(ITaskScheduler sched, Task t, ISchedulingContext context)
        {
            scheduler = sched;
            task = t;
            SchedulingContext = context;
#if DEBUG
            if (logger.IsVerbose2) logger.Verbose2("Created TaskWorkItem {0} for Id={1} State={2} with Status={3} Scheduler={4}",
                Name, task.Id, (task.AsyncState == null) ? "null" : task.AsyncState.ToString(), task.Status, scheduler);
#endif
        }
Пример #13
0
 public ScheduleTaskController(
     IScheduleTaskService scheduleTaskService, 
     ITaskScheduler taskScheduler, 
     IPermissionService permissionService, 
     IDateTimeHelper dateTimeHelper)
 {
     this._scheduleTaskService = scheduleTaskService;
     this._taskScheduler = taskScheduler;
     this._permissionService = permissionService;
     this._dateTimeHelper = dateTimeHelper;
 }
Пример #14
0
        public LoadBalancer(SendMessageCache cache, ITaskScheduler taskScheduler)
        {
            this.cache = cache;
            this.taskScheduler = taskScheduler;
            unsentMessages = new ConcurrentQueue<MessagePayload>();
            sentMessages = new ConcurrentDictionary<Guid, MessagePayload>();
            
            Messenger.Register<MessageRemovedFromCache>(m => FreeUpSlot(m.MessageId, m.Address, m.UseType));

            SendFeelerMessages();
        }
        public ImportController(
			IImportProfileService importService,
			IDateTimeHelper dateTimeHelper,
			ITaskScheduler taskScheduler,
			ILanguageService languageService)
        {
            _importProfileService = importService;
            _dateTimeHelper = dateTimeHelper;
            _taskScheduler = taskScheduler;
            _languageService = languageService;
        }
Пример #16
0
        public TaskSchedulerController(
			ITaskScheduler taskScheduler,
            IScheduleTaskService scheduledTaskService,
            ITaskExecutor taskExecutor,
            ICommonServices services)
        {
            this._taskScheduler = taskScheduler;
            this._scheduledTaskService = scheduledTaskService;
            this._taskExecutor = taskExecutor;
            this._services = services;
        }
Пример #17
0
        public LogFileProxy(ITaskScheduler taskScheduler, TimeSpan maximumWaitTime)
        {
            if (taskScheduler == null)
                throw new ArgumentNullException("taskScheduler");

            _taskScheduler = taskScheduler;
            _pendingSections = new ConcurrentQueue<KeyValuePair<ILogFile, LogFileSection>>();
            _listeners = new LogFileListenerCollection(this);

            _task = _taskScheduler.StartPeriodic(RunOnce, "Log File Proxy");
            _maximumWaitTime = maximumWaitTime;
        }
        // TODO IMM HI: can we update scheduler app without user name and password?
        public UpdateAppScheduleDeploymentStep(
            ITaskScheduler taskScheduler,
            string machineName,
            SchedulerAppProjectInfo schedulerAppProjectInfo,
            string executablePath,
            string userName,
            string password)
        {
            if (taskScheduler == null)
              {
            throw new ArgumentNullException("taskScheduler");
              }

              if (string.IsNullOrEmpty(machineName))
              {
            throw new ArgumentException("Argument can't be null nor empty.", "machineName");
              }

              if (schedulerAppProjectInfo == null)
              {
            throw new ArgumentNullException("schedulerAppProjectInfo");
              }

              if (string.IsNullOrEmpty(executablePath))
              {
            throw new ArgumentException("Argument can't be null nor empty.", "executablePath");
              }

              if (!Path.IsPathRooted(executablePath))
              {
            throw new ArgumentException(string.Format("Executable path ('{0}') is not an absolute path.", executablePath), "executablePath");
              }

              if (string.IsNullOrEmpty(userName))
              {
            throw new ArgumentException("Argument can't be null nor empty.", "userName");
              }

              if (string.IsNullOrEmpty(password))
              {
            throw new ArgumentException("Argument can't be null nor empty.", "password");
              }

              _taskScheduler = taskScheduler;
              _machineName = machineName;
              _schedulerAppProjectInfo = schedulerAppProjectInfo;
              _executablePath = executablePath;
              _userName = userName;
              _password = password;
        }
        public ScheduleTaskController(
            IScheduleTaskService scheduleTaskService, 
            ITaskScheduler taskScheduler, 
            IPermissionService permissionService, 
            IDateTimeHelper dateTimeHelper,
			ILocalizationService localizationService,
            IWorkContext workContext)
        {
            this._scheduleTaskService = scheduleTaskService;
            this._taskScheduler = taskScheduler;
            this._permissionService = permissionService;
            this._dateTimeHelper = dateTimeHelper;
            this._localizationService = localizationService;
            this._workContext = workContext;
        }
Пример #20
0
        public Generator(ITaskScheduler taskScheduler, ILog log)
        {
            if (taskScheduler == null)
                throw new ArgumentNullException("taskScheduler");
            if (log == null)
                throw new ArgumentNullException("log");

            _random = new Random();
            _taskScheduler = taskScheduler;
            _log = log;

            _messages = CreateMessages();

            _task = _taskScheduler.StartPeriodic(Update);
        }
        public DeploySchedulerAppDeploymentTask(
      IEnvironmentInfoRepository environmentInfoRepository,
      IArtifactsRepository artifactsRepository,
      ITaskScheduler taskScheduler,
      IPasswordCollector passwordCollector,
      SchedulerAppProjectInfo projectInfo,
      string projectConfigurationName,
      string projectConfigurationBuildId,
      string targetEnvironmentName)
            : base(environmentInfoRepository, targetEnvironmentName)
        {
            if (artifactsRepository == null)
              {
            throw new ArgumentNullException("artifactsRepository");
              }

              if (taskScheduler == null)
              {
            throw new ArgumentNullException("taskScheduler");
              }

              if (passwordCollector == null)
              {
            throw new ArgumentNullException("passwordCollector");
              }

              if (projectInfo == null)
              {
            throw new ArgumentNullException("projectInfo");
              }

              if (string.IsNullOrEmpty(projectConfigurationName))
              {
            throw new ArgumentException("Argument can't be null nor empty.", "projectConfigurationName");
              }

              if (string.IsNullOrEmpty(projectConfigurationBuildId))
              {
            throw new ArgumentException("Argument can't be null nor empty.", "projectConfigurationBuildId");
              }

              _artifactsRepository = artifactsRepository;
              _taskScheduler = taskScheduler;
              _passwordCollector = passwordCollector;
              _projectInfo = projectInfo;
              _projectConfigurationName = projectConfigurationName;
              _projectConfigurationBuildId = projectConfigurationBuildId;
        }
Пример #22
0
        protected AbstractDataSource(ITaskScheduler taskScheduler, DataSource settings, TimeSpan maximumWaitTime)
        {
            if (taskScheduler == null)
                throw new ArgumentNullException("taskScheduler");
            if (settings == null) throw new ArgumentNullException("settings");
            if (settings.Id == Guid.Empty) throw new ArgumentException("settings.Id shall be set to an actually generated id");

            _taskScheduler = taskScheduler;
            _settings = settings;
            _maximumWaitTime = maximumWaitTime;
            _counter = new LogFileCounter();

            _logFile = new LogFileProxy(taskScheduler, maximumWaitTime);
            _search = new LogFileSearchProxy(taskScheduler, _logFile, maximumWaitTime);
            CreateSearch();
        }
Пример #23
0
        public FilteredLogFile(ITaskScheduler scheduler, TimeSpan maximumWaitTime, ILogFile source, ILogEntryFilter filter)
            : base(scheduler)
        {
            if (source == null) throw new ArgumentNullException("source");
            if (filter == null) throw new ArgumentNullException("filter");

            _source = source;
            _filter = filter;
            _pendingModifications = new ConcurrentQueue<LogFileSection>();
            _indices = new List<int>();
            _buffer = new LogLine[BatchSize];
            _lastLogEntry = new List<LogLine>();
            _maximumWaitTime = maximumWaitTime;

            _source.AddListener(this, maximumWaitTime, BatchSize);
            StartTask();
        }
Пример #24
0
        public LogFileSearchProxy(ITaskScheduler taskScheduler, ILogFile logFile, TimeSpan maximumWaitTime)
        {
            if (taskScheduler == null)
                throw new ArgumentNullException("taskScheduler");
            if (logFile == null)
                throw new ArgumentNullException("logFile");

            _pendingMatches = new ConcurrentQueue<KeyValuePair<ILogFileSearch, List<LogMatch>>>();
            _logFile = logFile;
            _listeners = new List<ILogFileSearchListener>();
            _taskScheduler = taskScheduler;
            _syncRoot = new object();
            _matches = new List<LogMatch>();
            _maximumWaitTime = maximumWaitTime;

            _task = _taskScheduler.StartPeriodic(RunOnce, _maximumWaitTime, "Search Proxy");
        }
Пример #25
0
        public LogFile(ITaskScheduler scheduler, string fileName)
            : base(scheduler)
        {
            if (fileName == null) throw new ArgumentNullException("fileName");

            _fileName = fileName;
            _fullFilename = fileName;
            if (!Path.IsPathRooted(_fullFilename))
                _fullFilename = Path.Combine(Directory.GetCurrentDirectory(), fileName);

            _entries = new List<LogLine>();
            _syncRoot = new object();

            _previousLevel = LevelFlags.None;
            _levels = new List<KeyValuePair<int, LevelFlags>>();

            StartTask();
        }
Пример #26
0
        public LongPoller(
            IWebRequestor requestor, 
            ISerialiser formatter, 
            ITaskScheduler scheduler, 
            MessageReceiver receiver, 
            ITaskStarter starter)
        {
            Contract.Requires(requestor != null);
            Contract.Requires(formatter != null);
            Contract.Requires(scheduler != null);
            Contract.Requires(receiver != null);
            Contract.Requires(starter != null);

            this.requestor = requestor;
            this.formatter = formatter;
            this.scheduler = scheduler;
            this.receiver = receiver;
            this.starter = starter;
        }
Пример #27
0
        public SQLiteLogTable(ITaskScheduler scheduler, LogDataCache cache, string fileName)
        {
            if (scheduler == null)
                throw new ArgumentNullException("scheduler");
            if (cache == null)
                throw new ArgumentNullException("cache");
            if (fileName == null)
                throw new ArgumentNullException("fileName");

            _scheduler = scheduler;
            _cache = cache;
            _fileName = fileName;

            _listeners = new LogTableListenerCollection(this);
            _accessQueue = new LogDataAccessQueue<LogEntryIndex, LogEntry>();

            _schema = new SQLiteSchema(string.Empty);

            _task = _scheduler.StartPeriodic(Update, ToString());
        }
        // TODO IMM HI: can we update scheduler app without user name and password?
        public UpdateSchedulerTaskDeploymentStep(
            string machineName,
            string schedulerTaskName,
            string executablePath,
            string userName,
            string password,
            int scheduledHour,
            int scheduledMinute,
            int executionTimeLimitInMinutes,
            Repetition repetition,
            ITaskScheduler taskScheduler)
        {
            Guard.NotNull(taskScheduler, "taskScheduler");
              Guard.NotNullNorEmpty(machineName, "machineName");
              Guard.NotNullNorEmpty(schedulerTaskName, "schedulerTaskName");
              Guard.NotNullNorEmpty(executablePath, "executablePath");
              Guard.NotNullNorEmpty(userName, "userName");
              Guard.NotNullNorEmpty(password, "password");
              Guard.NotNull(repetition, "repetition");

              if (!Path.IsPathRooted(executablePath))
              {
            throw new ArgumentException(string.Format("Executable path ('{0}') is not an absolute path.", executablePath), "executablePath");
              }

              _taskScheduler = taskScheduler;
              _machineName = machineName;
              _schedulerTaskName = schedulerTaskName;
              _executablePath = executablePath;
              _userName = userName;
              _password = password;
              _scheduledHour = scheduledHour;
              _scheduledMinute = scheduledMinute;
              _executionTimeLimitInMinutes = executionTimeLimitInMinutes;
              _repetition = repetition;
        }
Пример #29
0
 protected Work(ITaskScheduler taskScheduler)
 {
     this.taskScheduler = taskScheduler;
 }
Пример #30
0
 /// <summary>
 ///     Schedule an action which includes physics interaction (e.g. applying force to an object) for every physics update.
 ///     See <see cref="ExecutionTargetContext.EveryPhysicsUpdate" />.<br />
 ///     Execution time depends on the engine implemention.
 /// </summary>
 /// <param name="action">The action to schedule. Must not block the thread.</param>
 /// <param name="owner">The owner of the task.</param>
 /// <param name="taskName">The tasks human friendly name.</param>
 public static ITask ScheduleEveryPhysicUpdate(this ITaskScheduler taskScheduler, object @owner, Action action, string taskName)
 => taskScheduler.ScheduleUpdate(@owner, action, taskName, ExecutionTargetContext.EveryPhysicsUpdate);
Пример #31
0
        private static LogFileSearch CreateNewSearch(ITaskScheduler scheduler, ILogFile logfile, string searchterm,
		                                              TimeSpan maximumwaittime)
        {
            return new LogFileSearch(scheduler, logfile, searchterm, maximumwaittime);
        }
Пример #32
0
 protected override ILogSource Create(ITaskScheduler taskScheduler, string fileName, ILogFileFormat format, Encoding encoding)
 {
     return(new TextLogSource(taskScheduler, fileName, format, encoding));
 }
Пример #33
0
 public IRoomController GetGameModeController(IRoomContext room, ITaskScheduler taskScheduler,
                                              IRoomPropertiesContainer roomPropertiesContainer)
 {
     return(new TestGameController(_logger, room));
 }
Пример #34
0
 /// <summary>
 /// The internal COM interface is released.  Further access to the
 /// object will throw null reference exceptions.
 /// </summary>
 public void Dispose()
 {
     Marshal.ReleaseComObject(its);
     its = null;
 }
Пример #35
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="taskScheduler"></param>
 public RawFileLogSourceFactory(ITaskScheduler taskScheduler)
 {
     _taskScheduler = taskScheduler;
 }
Пример #36
0
 /// <summary>
 /// Schedule func on scheduler
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="scheduler"></param>
 /// <param name="func"></param>
 /// <returns></returns>
 public static Task <T> Run <T>(this ITaskScheduler scheduler, Func <T> func) =>
 scheduler.Factory.StartNew(func);
Пример #37
0
 /// <summary>
 /// Schedule func on scheduler
 /// </summary>
 /// <param name="scheduler"></param>
 /// <param name="func"></param>
 /// <returns></returns>
 public static Task Run(this ITaskScheduler scheduler, Action func) =>
 scheduler.Factory.StartNew(func);
Пример #38
0
 /// <inheritdoc cref="RunOnMainThread"/>
 public static IScheduledTask RunTaskOnMainThread(this ITaskScheduler taskScheduler, ILifecycleObject owner, AsyncAction action, string taskName)
 {
     return(taskScheduler.RunOnMainThread(owner, action().GetAwaiter().GetResult, taskName));
 }
Пример #39
0
 /// <inheritdoc cref="ITaskScheduler.ScheduleAt"/>
 public static IScheduledTask ScheduleTaskAt(this ITaskScheduler taskScheduler, ILifecycleObject @owner,
                                             AsyncAction action, string taskName, DateTime date, bool runAsync = false)
 {
     return(taskScheduler.ScheduleAt(@owner, () => AsyncHelper.RunSync(() => action()), taskName, date, runAsync));
 }
Пример #40
0
 /// <inheritdoc cref="ScheduleDelayed"/>
 public static IScheduledTask ScheduleTaskDelayed(this ITaskScheduler taskScheduler, ILifecycleObject @object, AsyncAction action, string taskName, TimeSpan delay, bool runAsync = false)
 => taskScheduler.ScheduleAt(@object, () => AsyncHelper.RunSync(() => action()), taskName, DateTime.UtcNow + delay, runAsync);
Пример #41
0
 /// <summary>
 ///     Executes the given task roughly after the given delay.
 /// </summary>
 /// <param name="object">The owner of the task.</param>
 /// <param name="action">The action to schedule. Must not block thread if <i>runAsync</i> equals <b>false</b>.</param>
 /// <param name="taskScheduler">the Task Scheduler</param>
 /// <param name="delay">The delay.</param>
 /// <param name="runAsync">Defines if the task should run in a separate thread.</param>
 /// <param name="taskName">The tasks human friendly name.</param>
 public static IScheduledTask ScheduleDelayed(this ITaskScheduler taskScheduler, ILifecycleObject @object, Action action, string taskName, TimeSpan delay, bool runAsync = false)
 => taskScheduler.ScheduleAt(@object, action, taskName, DateTime.UtcNow + delay, runAsync);
        public void OnAuthorization(AuthorizationContext filterContext)
        {
            if (filterContext == null || filterContext.HttpContext == null)
            {
                return;
            }

            var request = filterContext.HttpContext.Request;

            if (request == null)
            {
                return;
            }

            if (filterContext.IsChildAction)
            {
                return;
            }

            lock (s_lock)
            {
                if (!s_initializing)
                {
                    s_initializing = true;

                    ILogger        logger        = EngineContext.Current.Resolve <ILogger>();
                    ITaskScheduler taskScheduler = EngineContext.Current.Resolve <ITaskScheduler>();

                    try
                    {
                        logger        = EngineContext.Current.Resolve <ILogger>();
                        taskScheduler = EngineContext.Current.Resolve <ITaskScheduler>();

                        var taskService    = EngineContext.Current.Resolve <IScheduleTaskService>();
                        var storeService   = EngineContext.Current.Resolve <IStoreService>();
                        var eventPublisher = EngineContext.Current.Resolve <IEventPublisher>();

                        var tasks = taskService.GetAllTasks(true);
                        taskService.CalculateFutureSchedules(tasks, true /* isAppStart */);

                        var baseUrl = CommonHelper.GetAppSetting <string>("sm:TaskSchedulerBaseUrl");
                        if (baseUrl.IsWebUrl())
                        {
                            taskScheduler.BaseUrl = baseUrl;
                        }
                        else
                        {
                            // autoresolve base url
                            taskScheduler.SetBaseUrl(storeService, filterContext.HttpContext);
                        }

                        taskScheduler.SweepIntervalMinutes = CommonHelper.GetAppSetting <int>("sm:TaskSchedulerSweepInterval", 1);
                        taskScheduler.Start();

                        logger.Information("Initialized TaskScheduler with base url '{0}'".FormatInvariant(taskScheduler.BaseUrl));

                        eventPublisher.Publish(new AppInitScheduledTasksEvent {
                            ScheduledTasks = tasks
                        });
                    }
                    catch (Exception ex)
                    {
                        s_errCount++;
                        s_initializing = false;
                        logger.Error("Error while initializing Task Scheduler", ex);
                    }
                    finally
                    {
                        var tooManyFailures = s_errCount >= 10;

                        if (tooManyFailures || (taskScheduler != null && taskScheduler.IsActive))
                        {
                            GlobalFilters.Filters.Remove(this);
                        }

                        if (tooManyFailures && logger != null)
                        {
                            logger.Warning("Stopped trying to initialize the Task Scheduler: too many failed attempts in succession (10+). Maybe uncommenting the setting 'sm:TaskSchedulerBaseUrl' in web.config solves the problem?");
                        }
                    }
                }
            }
        }
Пример #43
0
 /// <inheritdoc cref="ScheduleEveryAsyncFrame"/>
 public static IScheduledTask ScheduleTaskEveryAsyncFrame(this ITaskScheduler taskScheduler, ILifecycleObject owner, AsyncAction action, string taskName)
 => taskScheduler.ScheduleUpdate(owner, () => AsyncHelper.RunSync(() => action()), taskName, ExecutionTargetContext.EveryAsyncFrame);
Пример #44
0
 /// <summary>
 /// Schedule func on scheduler
 /// </summary>
 /// <param name="scheduler"></param>
 /// <param name="func"></param>
 /// <returns></returns>
 public static Task Run(this ITaskScheduler scheduler, Func <Task> func) =>
 scheduler.Factory.StartNew(func).Unwrap();
Пример #45
0
        /// <summary>
        /// Constructor to use Scheduled Tasks of the local computer.
        /// </summary>
        public ScheduledTasks()
        {
            CTaskScheduler cts = new CTaskScheduler();

            its = (ITaskScheduler)cts;
        }
 internal TaskFolder([NotNull] TaskService svc)
 {
     TaskService = svc;
     v1List      = svc.v1TaskScheduler;
 }
Пример #47
0
 public ObserveGroup(ITaskIdBuilder id, ITaskScheduler scheduler, GameObjectGroupSignal signal)
     : base(id, scheduler)
 {
     this.signal = signal;
 }
Пример #48
0
 internal ActionWork(ITaskScheduler taskScheduler, Action action)
     : base(taskScheduler)
 {
     this.action = action;
 }
Пример #49
0
 public override void InitializeTest()
 {
     m_concurrentStrandSchedulerPair = new ConcurrentStrandSchedulerPair(MAX_TASKS_CONCURRENCY);
     m_concurrentScheduler           = m_concurrentStrandSchedulerPair.AsioStrandcheduler;
     base.InitializeTest();
 }
Пример #50
0
 public FallbackController(ITaskScheduler taskScheduler)
 {
     // This is used to load TaskScheduler on startup without having to navigate to a Controller that uses.
     _taskScheduler = taskScheduler;
 }
Пример #51
0
 public PluginLogFileFactory(ITaskScheduler taskScheduler, IEnumerable <IFileFormatPlugin> plugins)
     : this(taskScheduler, plugins?.ToArray())
 {
 }
Пример #52
0
 internal TaskCollection(TaskService svc, Regex filter = null)
 {
     this.svc = svc;
     Filter   = filter;
     v1TS     = svc.v1TaskScheduler;
 }
Пример #53
0
 /// <summary>
 ///     Schedules an action for the next frame on a separate thread. See
 ///     <see cref="ExecutionTargetContext.NextPhysicsUpdate" />.
 /// </summary>
 /// <param name="action">The action to schedule. Must not block the thread.</param>
 /// <param name="owner">The owner of the task.</param>
 /// <param name="taskName">The tasks human friendly name.</param>
 public static ITask ScheduleEveryAsyncFrame(this ITaskScheduler taskScheduler, object @object, Action action, string taskName)
 => taskScheduler.ScheduleUpdate(@object, action, taskName, ExecutionTargetContext.EveryAsyncFrame);
Пример #54
0
 internal RunningTaskCollection(TaskService svc)
 {
     this.svc = svc;
     v1TS     = svc.v1TaskScheduler;
 }
Пример #55
0
 internal FunctionResultWork(ITaskScheduler taskScheduler, Func <TInput, TResult> func, TInput input)
     : base(taskScheduler)
 {
     this.func  = func;
     this.input = input;
 }
Пример #56
0
 public SeriesController(ILogger <SeriesController> logger, ITaskScheduler taskScheduler, IUnitOfWork unitOfWork)
 {
     _logger        = logger;
     _taskScheduler = taskScheduler;
     _unitOfWork    = unitOfWork;
 }
Пример #57
0
        public MainWindowViewModel(IApplicationSettings settings,
                                   DataSources dataSources,
                                   QuickFilters quickFilters,
                                   IActionCenter actionCenter,
                                   IAutoUpdater updater,
                                   ITaskScheduler taskScheduler,
                                   IAnalysisStorage analysisStorage,
                                   IDispatcher dispatcher,
                                   IEnumerable <IPluginDescription> plugins)
        {
            if (dataSources == null)
            {
                throw new ArgumentNullException(nameof(dataSources));
            }
            if (quickFilters == null)
            {
                throw new ArgumentNullException(nameof(quickFilters));
            }
            if (updater == null)
            {
                throw new ArgumentNullException(nameof(updater));
            }
            if (dispatcher == null)
            {
                throw new ArgumentNullException(nameof(dispatcher));
            }

            _applicationSettings = settings;

            _plugins  = plugins;
            _settings = new SettingsMainPanelViewModel(settings);
            _actionCenterViewModel = new ActionCenterViewModel(dispatcher, actionCenter);

            _analysePanel = new AnalyseMainPanelViewModel(_applicationSettings, dataSources, dispatcher, taskScheduler, analysisStorage);
            _analysePanel.PropertyChanged += AnalysePanelOnPropertyChanged;

            _logViewPanel = new LogViewMainPanelViewModel(actionCenter,
                                                          dataSources,
                                                          quickFilters,
                                                          _applicationSettings);
            _logViewPanel.PropertyChanged += LogViewPanelOnPropertyChanged;

            _timer = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(100)
            };
            _timer.Tick += TimerOnTick;
            _timer.Start();

            _autoUpdater                = new AutoUpdateViewModel(updater, settings.AutoUpdate, dispatcher);
            _showLogCommand             = new DelegateCommand(ShowLog);
            _showGoToLineCommand        = new DelegateCommand2(ShowGoToLine);
            _showQuickNavigationCommand = new DelegateCommand2(ShowQuickNavigation);

            _analyseEntry = new AnalyseMainPanelEntry();
            _rawEntry     = new LogViewMainPanelEntry();
            _topEntries   = new IMainPanelEntry[]
            {
                _rawEntry,
                _analyseEntry
            };

            _settingsEntry = new SettingsMainPanelEntry();
            _pluginsEntry  = new PluginsMainPanelEntry();
            _aboutEntry    = new AboutMainPanelEntry();
            _bottomEntries = new[]
            {
                _settingsEntry,
                _pluginsEntry,
                _aboutEntry
            };

            var selectedTopEntry    = _topEntries.FirstOrDefault(x => x.Id == _applicationSettings.MainWindow.SelectedMainPanel);
            var selectedBottomEntry = _bottomEntries.FirstOrDefault(x => x.Id == _applicationSettings.MainWindow.SelectedMainPanel);

            if (selectedTopEntry != null)
            {
                SelectedTopEntry = selectedTopEntry;
            }
            else if (selectedBottomEntry != null)
            {
                SelectedBottomEntry = selectedBottomEntry;
            }
            else
            {
                SelectedTopEntry = _rawEntry;
            }
        }
Пример #58
0
 public IDataSourceAnalyser Create(AnalyserId id, ITaskScheduler scheduler, ILogFile logFile,
                                   ILogAnalyserConfiguration configuration)
 {
     return(new DataSourcesAnalyser(id, TimeSpan.FromMilliseconds(100)));
 }
Пример #59
0
 /// <inheritdoc cref="ITaskScheduler.ScheduleUpdate"/>
 public static IScheduledTask ScheduleTaskUpdate(this ITaskScheduler taskScheduler, ILifecycleObject @owner,
                                                 AsyncAction action, string taskName, ExecutionTargetContext frame)
 {
     return(taskScheduler.ScheduleUpdate(@owner, () => AsyncHelper.RunSync(() => action()), taskName, frame));
 }
Пример #60
0
 /// <summary>
 ///     Schedules an action for the next frame on a separate thread. See
 ///     <see cref="ExecutionTargetContext.NextPhysicsUpdate" />.
 /// </summary>
 /// <param name="action">The action to schedule. Must not block the thread.</param>
 /// <param name="taskScheduler">the Task Scheduler</param>
 /// <param name="owner">The owner of the task.</param>
 /// <param name="taskName">The tasks human friendly name.</param>
 public static IScheduledTask ScheduleEveryAsyncFrame(this ITaskScheduler taskScheduler, ILifecycleObject owner, Action action, string taskName)
 => taskScheduler.ScheduleUpdate(owner, action, taskName, ExecutionTargetContext.EveryAsyncFrame);