如题

解决方案 »

  1.   

    用delegate
      
    *****************************************************************************
    欢迎使用CSDN论坛阅读器 : CSDN Reader(附全部源代码) 
    http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
      

  2.   

    想怎么表现?写日志?用log4net.显示在界面?用delegate(委托)
      

  3.   

    比如:Book mybook=new Book(bookid);System.Threading.Thread othread=new System.Threading.Thread(new System.Threading.ThreadStart(mybook.销毁));othread.Start();我想知道这本书的的销毁情况.
      

  4.   

    说得还不是很明确,那直接弹出个MessageBox提示不就行了吗?
      

  5.   

    Process process = new Process();
    process.StartInfo.FileName = "ping.exe";
    process.StartInfo.Arguments = "10.249.188.1";
    process.StartInfo.UseShellExecute = false;
    process.StartInfo.RedirectStandardOutput = true;
    process.Start();
    String resuilt = process.StandardOutput.ReadToEnd();
    process.Close();resuilt 是线程标准输出结果.  或者说, 就是本来应该显示在cmd窗口里的那些字符.
      

  6.   

    各位,我已经说了"比如"了.我的目的就是得到线程中方法处理的结果呀.而不需要在线程中MessageBox.
      

  7.   

    哦,大概明白你的意思了...其实也就是一个线程中参数传递的问题...给你提供回调的方法吧:使用回调方法检索数据,下面的示例演示了一个从线程中检索数据的回调方法。包含数据和线程方法的类的构造函数也接受代表回调方法的委托;在线程方法结束前,它调用该回调委托。using System;
    using System.Threading;
    public class ThreadWithState {
        private string boilerplate;
        private int value;
        private ExampleCallback callback;
        public ThreadWithState(string text, int number, 
            ExampleCallback callbackDelegate) 
        {
            boilerplate = text;
            value = number;
            callback = callbackDelegate;
        }
            public void ThreadProc() 
        {
            Console.WriteLine(boilerplate, value);
            if (callback != null)
                callback(1);
        }
    }
    public class Example 
    {
        public static void Main() 
        {
            ThreadWithState tws = new ThreadWithState(
                "This report displays the number {0}.",
                42,
                new ExampleCallback(ResultCallback)
            );        Thread t = new Thread(new ThreadStart(tws.ThreadProc));
            t.Start();
            Console.WriteLine("Main thread does some work, then waits.");
            t.Join();
            Console.WriteLine(
                "Independent task has completed; main thread ends."); 
        }    public static void ResultCallback(int lineCount) 
        {
            Console.WriteLine(
                "Independent task printed {0} lines.", lineCount);
        }
    }