public async Task Start(string [] args) { IServiceProvider provider = StaticServiceProvider.Provider; SessionProvider = provider.GetService <ISessionProvider <TUser> > ( ); CommandProvider = provider.GetService <ICommandProvider <TUser> > ( ); UserProvider = provider.GetService <ITelegramIdUserProvider <TUser> > ( ); PermissionProvider = provider.GetService <IUserPermissionProvider <TUser> > ( ); TaskDispatcher = provider.GetService <ITaskDispatcher> ( ); TaskDispatcher.Start( ); BotClient = new TelegramBotClient(BotToken, WebProxy); Logger.LogInformation("Connecting..."); User me = await BotClient.GetMeAsync( ); Logger.LogInformation("Use Bot {0}", me.Username); Console.Title = me.Username; BotClient.OnMessage += BotClient_OnMessage; BotClient.OnCallbackQuery += BotClient_OnCallbackQuery; BotClient.OnInlineQuery += BotClient_OnInlineQuery; BotClient.StartReceiving( ); }
public InstrumentProcessor(ITaskDispatcher taskDispatcher, IInstrument instrument) { _taskDispatcher = taskDispatcher; _instrument = instrument; _instrument.Error += OnError; _instrument.Finished += OnFinished; }
public override void Start(string [] args) { PerformanceCounterProvider provider = new PerformanceCounterProvider( ); provider.GetPerformanceCounter("a"); (string SourceCodeVersion, string Builder, DateTimeOffset ? BuildTime) ? a = typeof(ProgramBase <Program, ProgramExitCode, ProgramSetting, ProgramSettingCatalog>).Assembly. GetInformationalVersion( ); Thread thread = new Thread(DoSth); thread.Start( ); Dispatcher = StaticServiceProvider.Provider.GetService <ITaskDispatcher> ( ); Dispatcher.Start( ); OnetimeTask task1 = new OnetimeTask(PrintTime1, default); Dispatcher.Dispatch(task1); IntervalTask task2 = new IntervalTask( PrintTime2, TimeSpan.FromSeconds(1), priority: TaskPriority.Background); Dispatcher.Dispatch(task2); }
public InstrumentProcessor(ITaskDispatcher taskDispatcher, IInstrument instrument) { this.taskDispatcher = taskDispatcher; this.instrument = instrument; instrument.Error += InstrumentOnError; instrument.Finished += InstrumentOnFinished; }
public void Invoke(ITaskDispatcher dispatcher) { lock (this) { IsRunning = true; if (NextRun != null) { if (DateTimeOffset.Now >= NextRun) { LastRun = DateTime.Now; try { NextRun = Action ? .Invoke( ); } catch (Exception e) { Logger? .LogError(e, $"{nameof ( ScheduledTask )} thrown unhandled exception."); } RunCount++; } } IsRunning = false; } }
public InstrumentProcessor(ITaskDispatcher taskDispatcher, IInstrument instrument) { _taskDispatcher = taskDispatcher; _instrument = instrument; _instrument.Finished += (sender, eventArgs) => _taskDispatcher.FinishedTask(((InstrumentEventArgs)eventArgs).Task); }
public void Invoke(ITaskDispatcher dispatcher) { lock (this) { IsRunning = true; if (DateTimeOffset.Now >= NextRun) { LastRun = DateTime.Now; try { Action? .Invoke( ); } catch (Exception e) { Logger? .LogError(e, $"{nameof ( IntervalTask )} thrown unhandled exception."); } RunCount++; UpdateStatus( ); } IsRunning = false; } }
public InstrumentProcessor(ITaskDispatcher taskDispatcher, IInstrument instrument, IConsoleWriter console) { this.consoleWriter = console; this.dispatcher = taskDispatcher; this.instrument = instrument; this.instrument.Finished += this.InstrumentOnFinished; this.instrument.Error += this.InstrumentOnError; }
public InstrumentProcessor(ITaskDispatcher taskDispatcher, IInstrument instrument) { _taskDispatcher = taskDispatcher; _instrument = instrument; _instrument.Finished += (EventHandler)((sender, args) => { var processedTask = args as TaskEventArgs; _taskDispatcher.FinishedTask(processedTask.Task); }); }
internal SubscriptionToken(MessageBase messageBase, ITaskDispatcher dispatcher, Func <Task> func, Func <bool> pred) { _dispatcher = dispatcher; _func = func; _pred = pred; _messageBaseBase = messageBase; }
public static void ExecuteTask(this ITaskDispatcher self, Action action, int timeoutMs) { try { self.QueueTask(action).Wait(timeoutMs); } catch (AggregateException ex) { throw ex.Flatten().InnerException.PrepareForRethrow(); } }
public Analytics(ITaskDispatcher taskDispatcher, IServiceScopeFactory scopeFactory) : base(scopeFactory) { _taskDispacher = taskDispatcher; TopContributors = new List <Tuple <string, int> >(); // fire and forget // TODO: better? UpdateStatistics().Wait(); aTimer = new Timer(async a => { await UpdateStatistics(); }, null, 0, 5 * 60 * 1000); // 10 min }
public InstrumentProcessor(IInstrument instrument, ITaskDispatcher taskDispatcher, IConsole console) { this.instrument = instrument; this.taskDispatcher = taskDispatcher; this.console = console; this.instrument.Finished += (sender, args) => { this.taskDispatcher.FinishedTask(currentTasks.Dequeue()); }; this.instrument.Error += (sender, args) => { this.console.WriteLine(currentTasks.Dequeue()); }; }
public InstrumentProcessor(IInstrument instrument, ITaskDispatcher taskDispatcher, IConsole console) { this.instrument = instrument; this.taskDispatcher = taskDispatcher; this.console = console; this.instrument.Finished += (sender, args) => { this.taskDispatcher.FinishedTask(currentTasks.Dequeue()); }; this.instrument.Error += (sender, args) => { this.console.WriteLine(currentTasks.Dequeue()); }; }
public DashboardViewModel(IFeedServices feedServices, ITaskDispatcher dispatcher) { FeedServices = feedServices; Dispatcher = dispatcher; ListItems = new ObservableCollection <DashboardSideItemViewModel>(); LoadData(); var dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += (a, b) => { CycleImages(); }; dispatcherTimer.Interval = new TimeSpan(0, 0, 5); dispatcherTimer.Start(); }
public static T ExecuteTask <T>(this ITaskDispatcher self, Func <T> action, int timeoutMs) { try { using (Task <T> task = self.QueueTask <T>(action)) { if (!task.Wait(timeoutMs)) { throw new TimeoutException("Timed out waiting on task"); } return(task.Result); } } catch (AggregateException ex) { throw ex.Flatten().InnerException.PrepareForRethrow(); } }
public void Setup() { mocks = new MockRepository(); taskRepository = mocks.DynamicMock <IRepository <Task> >(); teamTaskStateRepository = mocks.DynamicMock <IRepository <TeamTaskState> >(); acceptedCodeRepository = mocks.DynamicMock <IRepository <AcceptedCode> >(); acceptedBadCodeRepository = mocks.DynamicMock <IRepository <AcceptedBadCode> >(); acceptedTipRepository = mocks.DynamicMock <IRepository <AcceptedTip> >(); dispatcherFactory = mocks.DynamicMock <ITaskDispatcherFactory>(); taskDispatcher = mocks.DynamicMock <ITaskDispatcher>(); game = new Game { Name = "Game" }; team = new Team { Name = "Team" }; }
public CrowdSourceController( ILoggerFactory loggerFactory, IDataLogic logic, ApplicationDbContext context, ITaskDispatcher taskDispatcher, ITextSanitizer textSanitizer, IDbConfig config, UserManager <ApplicationUser> userMan, IHttpContextAccessor httpContext ) { _context = context; _logger = loggerFactory.CreateLogger <CrowdSourceController>(); _logic = logic; _taskDispatcher = taskDispatcher; _textSanitizer = textSanitizer; _config = config; _httpContext = httpContext; _userMan = userMan; }
public ChatPageViewModel( IChatService chatService, IPageDialogService pageDialogService, IUserService userService, IApplicationContext applicationContext, ITimer timer, ITaskDispatcher taskDispatcher) { this._userService = userService; this._pageDialogService = pageDialogService; this._applicationContext = applicationContext; this._timer = timer; this._taskDispatcher = taskDispatcher; this.SendMessageCommand = new DelegateCommand(async() => { await SendMessage(); }); OnlineUserCollection = new ObservableCollection <string>(); if (chatService == null) { throw new ArgumentNullException(nameof(chatService)); } _chatService = chatService; }
public QueueController(ILoggerFactory loggerFactory, ITaskDispatcher taskDispatcher) { _logger = loggerFactory.CreateLogger <QueueController>(); _taskDispatcher = taskDispatcher; }
public void Setup() { mocks = new MockRepository(); taskRepository = mocks.DynamicMock<IRepository<Task>>(); teamTaskStateRepository = mocks.DynamicMock<IRepository<TeamTaskState>>(); acceptedCodeRepository = mocks.DynamicMock<IRepository<AcceptedCode>>(); acceptedBadCodeRepository = mocks.DynamicMock<IRepository<AcceptedBadCode>>(); acceptedTipRepository = mocks.DynamicMock<IRepository<AcceptedTip>>(); dispatcherFactory = mocks.DynamicMock<ITaskDispatcherFactory>(); taskDispatcher = mocks.DynamicMock<ITaskDispatcher>(); game = new Game { Name = "Game" }; team = new Team { Name = "Team" }; }
public ISubscriptionToken Subscribe(Func <Task> func, ThreadHandler runOnThread, Func <bool> shouldRunPredicate = null) { ITaskDispatcher taskDispatcher = TaskDispatchers[runOnThread]; return(AddSubscriber(new SubscriptionToken(this, taskDispatcher, func, shouldRunPredicate))); }
public static T ExecuteTask <T>(this ITaskDispatcher self, Func <T> action) { return(self.ExecuteTask <T>(action, -1)); }
public static void ExecuteTask(this ITaskDispatcher self, Action action) { self.ExecuteTask(action, -1); }
public MainViewModel(ISnackbarMessageQueue snackbarMessageQueue, ITaskDispatcher dispatcher) : base(dispatcher) { SnackbarMessageQueue = snackbarMessageQueue; CurrentViewModel = new DashboardViewModel(new FeedServices(), dispatcher); }
public void RegisterTaskDispatcher(ThreadHandler threadHandler, ITaskDispatcher taskDispatcher) { _taskDispatchers.Add(threadHandler, taskDispatcher); }
public TaskDispatcherScheduler(ITaskDispatcher dispatcher) { Invariant.ArgumentNotNull((object)dispatcher, "dispatcher"); this.dispatcher = dispatcher; }
public RootViewModel(ITaskDispatcher dispatcher) { this.dispatcher = dispatcher; }
public TaskManager(ITaskDispatcher dispatcher) : this() { _dispatcher = dispatcher; }
public TaskManager(ITaskDispatcher dispatcher, TaskMode mode) : this(dispatcher) { _mode = mode; }