Sunday, 19 October 2014

First go at async

Playing about with async so a really simple example partly ripped from illustrated C#.

picture of visual studio 2013 pro with console window open running async console app

namespace boredbasics
{
    class Program
    {
        static void Main(string[] args)
        {
            Task<int> t1 = 

            countCharsAsync(1, "http://stackoverflow.com/");
            Task<int> t2 = 

            countCharsAsync(2, "https://news.ycombinator.com/news");
            Task<int> t3 = 

            countCharsAsync(3, "http://www.bbc.co.uk/");

            Console.WriteLine("call one:\t{0: 20}", t1.Result);
            Console.WriteLine("call two:\t{0: 20}", t2.Result);
            Console.WriteLine("call three:\t{0: 20}", t3.Result);
            Console.Read();
        }

        public static async Task<int> countCharsAsync(int id, string uri)
        {
            Console.WriteLine("Starting count chars {0}", id);
            var wc = new WebClient();
            string result = await wc.DownloadStringTaskAsync(new Uri(uri));

            Console.WriteLine("char count complete {0}", id);
            return result.Length;
        }
    }
}


A few things to add to my list, don't make me think has been ordered for uni reading, ASP.Net MVC book arrived yay!

If any other job seekers are reading, I was hanging around imgur lots are seeing the same things with junior tech jobs.

commant stating Must have 5 years experience milking purple Himalayan goats...and know html




Reading about the gingery furnace and found a few places to order a good metal bucket for the furnace and a smaller bucket to create the void.

http://www.oipps.co.uk/
http://artisanfoundry.co.uk/

Can't wait to get setup and build a lathe.

No comments:

Post a Comment