Reputation: 103
I want to load content in a different thread.
When I call the Load-Method normally, I get a loading time of ~0.6 Seconds
public void Load()
{
TLoad();
}
private void TLoad()
{
[....]
}
But if I call the TLoad() method using a Thead Object, I get unbelievable high loading times
Thread loadthread;
public void Load()
{
loadthread = new Thread(new ThreadStart(TLoad));
loadthread.Start();
}
private void TLoad()
{
[....]
}
which last about 12 up to 30 times longer than the normal loading time. (7-27 sec)
I've already tried to set Thread.Priotity to ThreadPriority.High etc., but the performance didn't increase.
Upvotes: 0
Views: 474
Reputation: 62093
I would suggest using a profiler.
It is quite wrong to say the thread is slow when the processing is. Seriously. The thread overhead will be quite zero.
Likely you do something in TLoad that is not thread safe - sadly it is the code you insist on not showing. HTML requests for example may line up with only X per domain executing at the same time. A profiler would show you this.
Upvotes: 8