示例#1
0
        //public async Task TM1Async()
        //{
        //    HttpClient hc = new HttpClient();
        //    var res = await hc.GetAsync("http://mradvice.arxone.com/");
        //    if(res.StatusCode == System.Net.HttpStatusCode.OK)
        //    {
        //        var content = await res.Content.ReadAsStringAsync();
        //    }
        //}

        public async Task <string> TM2Async()
        {
            try
            {
                return(await NestedAsync.TM3Async());
            }
            catch (Exception ex)
            {
                //!!!!!!! here will be the exception
                Console.WriteLine(ex.ToString());
                throw ex;
            }
        }
示例#2
0
        public void NestedAsyncTest()
        {
            NestedAsync c = new NestedAsync();

            //Here is the first problem to solve (can't build: Couldn't find an instruction, maybe it was removed. It's still being referenced by some code or by the PDB)
            //Task.Run(async () => { await c.TM1Async(); });

            var t = Task.Run(() =>
            {
                try
                {
                    // c1 c = new c1();
                    var r = c.TM2Async();
                    r.Wait();
                    Assert.AreEqual("OK", r.Result);
                }
                catch (Exception ex)
                {
                    //Console.WriteLine(ex.ToString());
                }
            });

            t.Wait();
        }
示例#3
0
        private static async Task <string> TM3Async()
        {
            var s1 = await NestedAsync.GetFile();

            return("OK");
        }