示例#1
0
        public static async Task <string> MainAsync()
        {
            #if debug
            Console.WriteLine("Main thread before GetAPI await : " + Thread.CurrentThread.ManagedThreadId);
            #endif

            TwitchAPI twitchAPI = new TwitchAPI();
            twitchAPI.BuildConfiguration();
            twitchAPI.SetupHttpClient();

            bool success = await twitchAPI.BuildChannelDictionary();

            if (!success)
            {
                return("Error connecting to API");
            }

            #if debug
            Console.WriteLine("Main thread after GetAPI await : " + Thread.CurrentThread.ManagedThreadId);
            #endif

            StatisticsService ss = new StatisticsService(new PRIVMSG());
            success = await ss.StartService(twitchAPI);

            if (!success)
            {
                return("Error getting emoticons");
            }

            #if debug
            Console.WriteLine("Main thread before ReportStatistics : " + Thread.CurrentThread.ManagedThreadId);
            #endif
            //intentionally not awaited so we can fire and forget our while loop, yields to this calling code after first await
            var ignore = ss.ReportStatistics(5000);
            #if debug
            Console.WriteLine("Main thread after ReportStatistics: " + Thread.CurrentThread.ManagedThreadId);
            #endif

            return(await ConnectIRC(ss));//Await this loop its our main logic loop
        }