How to Handle a large number of WebClient request?
I need to handle 500+ Http Request per seconds by using WebClient. And I also want to show the status of those request in Listview subitem.
I tried 5/10 Http Request per second but it freezes The ui.
I know a little bit about Thread But I heard it depends on hardware capacity. :ehh:
- So how Can I optimize it? :confused:
- How can I handle a large number of request without freezing my ui? :confused:
Re: How to Handle a large number of WebClient request?
The number of concurrent tasks does indeed depend on hardware capacity but that's not an argument for or against using multiple threads. If your hardware can't handle the load then nothing will help other than better hardware. Do some research on multi-threading and parallelism to get a grounding. The WebClient class even has asynchronous methods built in. Whatever else you do though, don't do any time-consuming work on the UI, whether it's one task or 500+ per second.
Re: How to Handle a large number of WebClient request?
Quote:
Originally Posted by
jmcilhinney
Do some research on multi-threading and parallelism to get a grounding.
Is it similar like Thread Pool or something else?
Re: How to Handle a large number of WebClient request?
The ThreadPool class is one option when it comes to multi-threading, but one of many. The idea is that, instead of creating Thread objects yourself, you simply queue up work items for the ThreadPool and it executes of on different threads as it sees fit. There are advantages in that Threads get reused so there's less overhead and the maximum number of threads is also managed for you. There are a number of instances in .NET programming where the ThreadPool is used indirectly, e.g. the BackgroundWorker class raises its DoWork event on a ThreadPool thread.