http://dev.csdn.net/article/18/18280.shtm

解决方案 »

  1.   

    use an event, like AutoResetEvent  or ManualResetEvent, seeSynchronizing Data for Multithreading
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconmanagedthreadingsupport.aspPractical Multithreading for Client Apps
    http://msdn.microsoft.com/msdnmag/issues/04/01/NET/default.aspx
      

  2.   

    1:线程池中线程完成后如何主动告知主线程,可以使线程池中线程在完成时候引发事件然后交与主线程处理吗?或者有别的方法。最简单的就是象楼上所说的用AutoResetEvent,
    但缺陷在于不能用call back 返回数据
    只能通过公共变量来传递数据
    更灵活的方法是用 delegate.BeginInvoke( AsyncCallback ...)
    但这就不是用thread pool 里面的thread 了2:将包涵线程池的类编译成DLL后在ASP.NET中调用会出现什么情况?是不是所有用户调用生成的线程都在一个线程池中,那么进行线程池管理的时候会混淆不同用户生成的线程。是的,因为都在同一个asp.net 的process 里面
    thread pool 本身不会混淆哪个是哪个
    至于你的数据就要看你自己的code 怎么处理了
      

  3.   

    对不起,我上面说错了一点,你用BeginInvoke 的时候其实也是在用thread pool 里面的thread 来完成任务,不过是.net framework 代你用了,不需要你自己QueueUserWorkItem
      

  4.   

    The CLR assigns the threads from the thread pool to the tasks and releases them to the pool once the task is completed. There is no direct way to cancel a task once it has been added to the queue.Thread pooling is an effective solution for situations where tasks are short lived, as in the case of a web server satisfying the client requests for a particular file. A thread pool should not be used for extensive or long tasks.Thread pooling is a technique to employ threads in a cost-efficient manner, where cost efficiency is defined in terms of quantity and startup overhead. Care should be exercised to determine the utilization of threads in the pool. The size of the thread pool should be fixed accordingly.All the threads in the thread pool are in multithreaded apartments. If we want to place our threads in single-thread apartments then a thread pool is not the way to go.If we need to identify the thread and perform various operations, such as starting it, suspending it, and aborting it, then thread pooling is not the way of doing it.Also, it is not possible to set priorities for tasks employing thread pooling.There can be only one thread pool associated with any given Application Domain.If the task assigned to a thread in the thread pool becomes locked, then the thread is never released back to the pool for reuse. These kinds of situations can be avoided by employing effective programmatic skills.
    ------------------------------------------------------
    所以只有在一个线程结束时考虑使用delegate通知主线程