I am connecting to Gmail account using TCP client for reading emails. It returns SslStream for the TCP connection. It works fine for single thread environment but performance is very poor in terms of speed.
I need to optimize the project so that its speed can be increased. I have implemented multithreading which increases the speeed but application gets hang at some point.
Is it thread safe to use TCP connection (global member)?
OR Can I create multiple TCP connections and pass to the thread method to increase the speed ?
OR is there any other better way for doing this?
TCPClient m_TCPclient
SslStream sslStream;
private void createTCP()
{
// creating tcp and sslstream
}
private void authenticateUser()
{
// authenticating the user
}
private void getUserdata()
{
// iterating folders and its items
foreach(string emailID in IDList)
{
//Thread implementation
}