ASP.NET温故而知新学习系列之ASP.NET多线程编程—.NET下的多线程
上一篇:http://www.2cto.com/kf/201203/123733.html
阅读目录
  一:实例
  一:实例
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading;
  namespace ThreadDelegate
  class Program
     {
        static void Main(string[] args)
        {
            Thread thread = SimpleThread.CreateThread(new SimpleThread.MyDelegate(User.DelegateMethod), "从小就犯困");
            thread.Start();
            thread.Join(Timeout.Infinite);
            Console.ReadKey();
        }
    }
    class User
    {
        //step2定义一个静态方法
        public static void DelegateMethod(object obj)
        {
            Console.WriteLine("我的名字叫:" + obj);
        }
    }
   
    class SimpleThread
    {
        //step1声明一个委托
        public delegate void MyDelegate(object obj);
          /// <summary>
          /// 创建一个用户类
        /// </summary>
         public class User
         {
              public object _name;//名字
              public MyDelegate mydelegate;
              /// <summary>
              /// 得到名字www.2cto.com
              /// </summary>
              public void GetName()
              {
                  mydelegate(_name);
              }
         }
	
相关新闻>>
- 发表评论
- 
				
- 最新评论 进入详细评论页>>



