Beispiel #1
0
        public Task <MyObj> ShowAsync(bool flag)
        {
            MyObj        xxx;
            Task <MyObj> tmo;

            if (flag)
            {
                tmo = Task.Run(() =>
                {
                    xxx = new MyObj();
                    Console.WriteLine("Hello");
                    xxx.i = 5;
                    return(xxx);
                });
            }
            else
            {
                tmo = Task.Run(() =>
                {
                    xxx = new MyObj();
                    Console.WriteLine("Hello");
                    xxx.i = 7;
                    return(xxx);
                });
            }
            return(tmo);
        }
Beispiel #2
0
        public static MyObj bazIt()
        {
            MyObj bazObj = new MyObj();

            counter++;
            return(bazObj);
        }
Beispiel #3
0
        public static void Main(String[] args)
        {
            T4         demo = new T4();
            WrapperObj zzz  = demo.CallAsync().Result;

            zzz.Process();
            Iterator.barIt();
            AnonymousFunction.barAnon();

            IDictionary <string, MyObj> dict;

            dict = new Dictionary <string, MyObj>();
            dict.Add("aaa", new MyObj());
            MyObj yyy = dict["aaa"];
        }
Beispiel #4
0
        public async Task <WrapperObj> CallAsync()
        {
            MyObj      firstObj  = new MyObj();
            WrapperObj wObj      = new WrapperObj(firstObj);
            MyObj      secondObj = null;

            try
            {
                secondObj = await ShowAsync(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            wObj.mo = secondObj;
            return(wObj);
        }
Beispiel #5
0
 public static void barAnon()
 {
     MyObj      anonObj  = new MyObj();
     WrapperObj barWObj  = fooAnon(paramObj => new WrapperObj(paramObj), anonObj);
     MyObj      finalObj = barWObj.mo;
 }
Beispiel #6
0
        static WrapperObj fooAnon(Func <MyObj, WrapperObj> anonFuncParam, MyObj aaa)
        {
            WrapperObj fooWObj = anonFuncParam(aaa);

            return(fooWObj);
        }
Beispiel #7
0
 public WrapperObj(MyObj arg)
 {
     mo = arg;
 }