本帖最后由 wanyeye 于 2014-01-20 13:30:59 编辑

解决方案 »

  1.   

     class Program
        {
            public delegate void OnFileChange(int num);//定义委托
            public class FileListen
            {
                public event OnFileChange OnFileChangeEvent;//定义事件
                public void test()
                {
                    for (int i = 1; i <= 100; i++)
                    {                    
                        OnFileChangeEvent(i); //事件发生                          
      
                       }
                }
                }
            }
     
     
            static void Main(string[] args)
            {
                FileListen fl = new FileListen();
                fl.OnFileChangeEvent += OutPut;//绑定具体方法到事件
                fl.test();
            }
            private static void OutPut(int num)
            {
                Console.WriteLine(num);
            }
        }
      

  2.   

    因为Console.ReadKey()需要等待按键按下才行,不按键的话就会一直卡在ReadKey
      

  3.   

    ReadKey 方法会一直等待,也就是阻止发出 ReadKey 方法的线程,直到按下某个字符或功能键。按下字符或功能键的同时可以按下 Alt、Ctrl 或 Shift 修改键中的一个或多个。但是,仅按下修改键不会使 ReadKey 方法返回。