How do I improve the performance of the following situation?
I have an application that accepts multiple connections across a network. The application is written in C# and accepts Socket connections. Every five minutes, the application needs to perform a function call that updates the application and reports information back to the sockets. Truncated code follows
...
{
new Thread(Loop).Start();
}
public Loop()
{
...
while (true)
{
...
string line = user.Read();
...
}
...
}
The above code is what is run when a Socket is connected to the server. The following code is what is run every five minutes.
...
{
new Thread(TryTick).Start();
}
public void TryTick()
{
while(true)
{
Tick();
Thread.Sleep(new TimeSpan(0, 5, 0));
}
}
Tick() does some File I/O operations as well as parsing a very limited (under 1MB) set of XML data. However, this code will tax my processor more than I had thought it would. Once a tick occurs, the system seems to grab an entire Core of my dual core development machine and doesn't let go. This seems to be something fairly simple, but perhaps I am doing it the easy way instead of the fast way.
This system is meant to handle up to 100 users, much more data and have a response time of under 1 second during load, so performance is an issue.