Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

C#
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)
    {
    }
}
Posted
Comments
Pascal-78 12-Dec-13 4:28am    
Did you check that ProcessData method ends and the completedCallback method is called and ended?
May be you can add those 2 methods in your question.
[no name] 17-Dec-13 18:59pm    
What do you think is happening? When you say "application stops working" what do you mean? Have you set up any tests to confirm this application actually works? I don't think it does.
As has been suggested by Pacal_78 do a little bit of tracking to confirm that it works. That will give you the answer.

1 solution

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!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900