线程池中的线程用完了 [英] Running out of threads in threadpool

查看:110
本文介绍了线程池中的线程用完了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个充当中间人的应用程序。它通过套接字将来自多台机器和fowards的数据传输到客户端机器。每次收到数据时都会创建新线程并将数据发送到客户端。池中的一个点可用线程变为零,应用程序停止工作。我甚至尝试使用ThreadPool.QueueUserWorkItem。



这是创建新线程的函数。



I have an application that acts as an intermideate. It takes data from multiple machines and fowards to client machine through sockets. Every time the data is received new thread is created and data is sent to client.At one point available threads in pool becomes zero and application stops working.I even tried using ThreadPool.QueueUserWorkItem.

This is the function where new thread is created.

public void SendFeed(string data, string Key)
{
    Datadelegate _ProcessData = new Datadelegate(ProcessData);
    Form1.countEQ = Form1.countEQ + 1;
    TCPListenerForm.DataClass sObj = new TCPListenerForm.DataClass();
    sObj.DataByte = data;
    sObj.Key = Key;
    try
    {
        _ProcessData.BeginInvoke(sObj, completedCallback, null);
    }
    catch (Exception ex)
    {
    }
}

推荐答案

没有什么只是在那里调试并检查datareceived,如果它不是new,那么编写用于在catch块中创建新线程的代码!
nothing yar just do debug there and check datareceived and if its not create new then then write code for creating new thread in catch block understood!


这篇关于线程池中的线程用完了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆