블로그 이미지
SQL Server VS. 석이 minsouk@hotmail.com MSSQL 쿼리성능 관련해 궁금한 사항이 있다면 언제나 누구나 TeamViewer + Line (네이버 japan 메신저) 에 minsouk1 추가 후 연락주세요~ 010-9967-0955 보미아빠

카테고리

보미아빠, 석이 (452)
밥벌이 (16)
싸이클 (1)
일상 (1)
Total222,037
Today129
Yesterday150

달력

« » 2018.06
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30

공지사항

'2018/06'에 해당되는 글 1건

  1. 2018.06.29 c# event

c# event

분류없음 / 2018.06.29 15:55

//using System;

//using System.Collections.Generic;

//using System.Linq;

//using System.Text;

//using System.Threading.Tasks;

//using System.Configuration;

//using System.Threading;


//namespace ConsoleApp1

//{

//    public class EvenNumberEventArgs : EventArgs

//    {

//        public EvenNumberEventArgs(int i)

//        {

//            this.I = i;

//        }

//        public int I { get; set; }

//    }


//    class Program

//    {

//        static void Main(string[] args)

//        {

//            new Program().Run();

//        }


//        void Run()

//        {

//            Config config = Config.Instance;

//            EventProcess ep = new EventProcess();

//            //Console.WriteLine(config.SampleApplication);


//            for (int i = 0; i < 10; i++)

//            {

//                config.NumberCheck(i);

//            }

//        }

//    }


//    public sealed class Config

//    {

//        private static readonly Lazy<Config> lazy =

//            new Lazy<Config>(() => new Config(), LazyThreadSafetyMode.ExecutionAndPublication);


//        public static Config Instance { get { return lazy.Value; } }


//        private Config()

//        {

//            //this.SampleApplication = ConfigurationManager.AppSettings["sampleApplication"];

//        }


//        //public string SampleApplication { get; } = string.Empty;


//        public event EventHandler<EvenNumberEventArgs> MyEvent;


//        public void NumberCheck(int i)

//        {

//            if (i % 2 == 0)

//                MyEvent?.Invoke(this, new EvenNumberEventArgs(i));

//        }

//    }


//    class EventProcess

//    {

//        public EventProcess()

//        {

//            Config.Instance.MyEvent += EvenNumber;

//        }

//        void EvenNumber(object o, EvenNumberEventArgs args)

//        {

//            Console.WriteLine(o.GetType());

//            Console.WriteLine(string.Format("this is even Number : {0}", args.I));

//        }

//    }


//}




using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading;

using System.Threading.Tasks;

 

namespace ConsoleApp1

{



    class Program

    {

        static void Main(string[] args)

        {

            new Program().Run();

        }


        void Run()

        {

            Config config = Config.Instance;

            new EventProcess();

            //Console.WriteLine(config.SampleApplication);

            for (int i = 0; i < 10; i++)

            {

                config.NumberCheck(i);

            }

        }

    }


    

    public sealed class Config

    {

        private static readonly Lazy<Config> lazy =

            new Lazy<Config>(() => new Config(), LazyThreadSafetyMode.ExecutionAndPublication);


        public static Config Instance { get { return lazy.Value; } }

        

        private Config()

        {

            //this.SampleApplication = ConfigurationManager.AppSettings["sampleApplication"];

        }


        public Action<object, EvenNumberEventArgs> MyEvent;


        public void NumberCheck(int i)

        {

            if (i % 2 == 0)

                MyEvent?.Invoke(this, new EvenNumberEventArgs(i));

        }


        public class EvenNumberEventArgs : EventArgs

        {

            public EvenNumberEventArgs(int i)

            {

                this.I = i;

            }

            public int I { get; set; }

        }

    }


    class EventProcess

    {

        public EventProcess()

        {

            Config.Instance.MyEvent += EvenNumber;

        }


        void EvenNumber(object o, Config.EvenNumberEventArgs args)

        {

            Console.WriteLine(o.GetType());

            Console.WriteLine(string.Format("this is even Number : {0}", args.I));

        }

    }

}

Posted by 보미아빠

최근에 달린 댓글

최근에 받은 트랙백

글 보관함