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 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); }