JD.
JD.

Reputation: 15551

Silverlight application not responding when multiple threads launched

I have a silverlight application which kicks off a number of jobs on the server side. Each job is a unit of work which are independent of each other.

I used Parallel.ForEach() and it works fine however I realized that if I had a large number of jobs (say over 300), when the thread count increases by 50 the silverlight application seems to stop responding (it does not freeze the browser but a grid which should have data populated in it is empty and the little doughnut keeps spinning).

Only when the thread counts drop again (i.e. all the jobs have finished processing) does the grid get populated.

I am testing with the Asp.net Development servers (cassini based) and was wondering has something to do with it.

I also switched my code to use the async programming model but I got the same problem as the threads increased.

Any ideas what may be causing this?

JD

I was thinking about doing ThreadPool.SetMaxThread() but I read somewhere that this may not work for web hosted apps.

Upvotes: 2

Views: 308

Answers (1)

AnthonyWJones
AnthonyWJones

Reputation: 189457

If you go gobbling up all the threads with a Parallel for each then there aren't any threads left available to service the WCF requests that your Grid is likely depending on to fetch the data it needs to display.

You would probably want to use the ParallelOptions parameter in the ForEach method to specify the maximum number of parallel operations dispatched at one time.

Upvotes: 5

Related Questions