示例#1
0
        public async Task <int> SimpleGoAsync()
        {
            var apiFetcherAsync = new ApiFetcherAsync();

            return(await apiFetcherAsync.Fetch());

            /*
             * var card = apiFetcherAsync.Fetch().Result;
             * Logger.Log($"SimpleGoAsync result: {card}");
             */
        }
示例#2
0
        public void MultiGoAsync()
        {
            var numTasks = 10;
            var tasks    = new List <Task <int> >();

            for (int i = 1; i < numTasks; i++)
            {
                var apiFetcherAsync = new ApiFetcherAsync();
                var task            = apiFetcherAsync.Fetch();
                tasks.Add(task);
            }
            Task.WhenAll(tasks);
        }