I have a C# winform application. it has many forms with different functionalities. These forms wrap to a WCF service. for example
form1 calls serviceMethod1 continuously and updates the results
form2 calls serviceMethod2 continuously and updates the results
The calls are made in a different thread per each form, but this is ending up with too many threads as we have many forms. Is this bad and why? and is there a way to avoid this given my scenario?
Regards
How many threads are you talking about? If you have a lot of threads, you’ll lose a bit of performance due to context switching – but in practice I wouldn’t expect this to become a significant problem until you have an awful lot of them.
One alternative would be to use a
Timerthough (it sounds like aSystem.Timers.TimerorSystem.Threading.Timerwould be most appropriate) – schedule each service call to be made on a regular basis, and the timer will use the threadpool to fire the calls. I suspect that although you say you’re calling the services “continuously” you actually mean you’re doing it regularly – which is exactly the kind of situation a timer is good for.