Skip to main content
Explicitly added the implied context
Source Link
Zack
  • 1.9k
  • 10
  • 13

ThreadsBackground threads tend to run at 100% CPU utilization unless you do something to prevent it. If your requirements allow for it, try adding a Thread.Sleep(10) (or some other number) to the code.

if (networkStream.DataAvailable)
{
    //...
}
else
{
    Thread.Sleep(10);
}

If you can't do that, when you start the new thread, try setting the thread priority to low or tweaking other related settings.

Threads tend to run at 100% CPU utilization unless you do something to prevent it. If your requirements allow for it, try adding a Thread.Sleep(10) (or some other number) to the code.

if (networkStream.DataAvailable)
{
    //...
}
else
{
    Thread.Sleep(10);
}

If you can't do that, when you start the new thread, try setting the thread priority to low or tweaking other related settings.

Background threads tend to run at 100% CPU utilization unless you do something to prevent it. If your requirements allow for it, try adding a Thread.Sleep(10) (or some other number) to the code.

if (networkStream.DataAvailable)
{
    //...
}
else
{
    Thread.Sleep(10);
}

If you can't do that, when you start the new thread, try setting the thread priority to low or tweaking other related settings.

Source Link
Zack
  • 1.9k
  • 10
  • 13

Threads tend to run at 100% CPU utilization unless you do something to prevent it. If your requirements allow for it, try adding a Thread.Sleep(10) (or some other number) to the code.

if (networkStream.DataAvailable)
{
    //...
}
else
{
    Thread.Sleep(10);
}

If you can't do that, when you start the new thread, try setting the thread priority to low or tweaking other related settings.