线程 Thread 传参数

 

        private static void IsVMStateChanged(object status)
        {
        
            object[] parms = (object[])status;
            string machineId = (string)parms[0];
            VM vm = ShareFactory.GetVMByID(new Guid(machineId));
            if (vm.StatusString.Equals("Creating..."))
            {

                System.Threading.Thread.Sleep(1000);
                Thread threadWithParam = new Thread(new ParameterizedThreadStart(IsVMStateChanged));
                threadWithParam.Start(new object[] { machineId});
            }
            else if (vm.StatusString.Equals("Running"))
            {
              //do something

            }                        
        }

 

Call Method:

   IsVMStateChanged(new object[] { machineId});

 

posted on 2009-01-20 19:39  newr2006  阅读(2732)  评论(0编辑  收藏  举报

导航