如:  private void btnJieYa_Click(object sender, EventArgs e)
{
Thread thread = new Thread(new ThreadStart(RARExtract));
 thread.Start();
}请问RARExtract后面的参数该如何处理!!
   public static bool RARExtract(string path, string rarPath, string rarName)
        {
            bool flag = false;
            string rarexe;
            RegistryKey regkey;
            Object regvalue;
            string cmd;
            ProcessStartInfo startinfo;
            Process process;
            try
            {
                regkey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.exe");
                regvalue = regkey.GetValue("");
                rarexe = regvalue.ToString();
                regkey.Close();
                // rarexe = rarexe.Substring(1, rarexe.Length - 7);                Directory.CreateDirectory(path);
                //解压缩命令,相当于在要压缩文件(rarName)上点右键->WinRAR->解压到当前文件夹
                cmd = string.Format("x {0} {1} -y",
                                    rarName,
                                    path);
                startinfo = new ProcessStartInfo();
                startinfo.FileName = rarexe;
                startinfo.Arguments = cmd;
                startinfo.WindowStyle = ProcessWindowStyle.Hidden;                startinfo.WorkingDirectory = rarPath;
                process = new Process();
                process.StartInfo = startinfo;
                process.Start();
                process.WaitForExit();
                if (process.HasExited)
                {
                    flag = true;
                }
                process.Close();
                MessageBox.Show("解压完成!");
            }
            catch (Exception e)
            {
                throw e;
            }
            return flag;
        }

解决方案 »

  1.   

    用这个创建线程:
    Thread(ParameterizedThreadStart) 就可以传递参数了,是object的参数,你可以将你的那些参数封装成一个类,实例化该类,赋值参数后,传递过去!
    public Thread(
    ParameterizedThreadStart start
    )
    public delegate void ParameterizedThreadStart(
    Object obj
    )
      

  2.   

    msdn的示例代码:using System;
    using System.Threading;public class Work
    {
        public static void Main()
        {
            // To start a thread using a shared thread procedure, use
            // the class name and method name when you create the 
            // ParameterizedThreadStart delegate. C# infers the 
            // appropriate delegate creation syntax:
            //    new ParameterizedThreadStart(Work.DoWork)
            //
            Thread newThread = new Thread(Work.DoWork);        // Use the overload of the Start method that has a
            // parameter of type Object. You can create an object that
            // contains several pieces of data, or you can pass any 
            // reference type or value type. The following code passes
            // the integer value 42.
            //
            newThread.Start(42);        // To start a thread using an instance method for the thread 
            // procedure, use the instance variable and method name when 
            // you create the ParameterizedThreadStart delegate. C# infers 
            // the appropriate delegate creation syntax:
            //    new ParameterizedThreadStart(w.DoMoreWork)
            //
            Work w = new Work();
            newThread = new Thread(w.DoMoreWork);        // Pass an object containing data for the thread.
            //
            newThread.Start("The answer.");
        }    public static void DoWork(object data)
        {
            Console.WriteLine("Static thread procedure. Data='{0}'",
                data);
        }
        public void DoMoreWork(object data)
        {
            Console.WriteLine("Instance thread procedure. Data='{0}'",
                data);
        }
    }
      

  3.   

    Thread(ParameterizedThreadStart)