Home > Net >  C # how to control the user requests?
C # how to control the user requests?

Time:11-04

Ask a question:
There is a demand to save users to upload video files, (client is write a Windows service, regular query to upload), now need to limit the number of users transfer files at the same time 5 to 10 what of, don't care about the efficiency, complete line, the what?
Colleagues say thread pool, but recently the thread pool, a need to create a large number of threads used when, this don't feel for me? Have a big kind under the light?

CodePudding user response:

SemaphoreSlim this good


As for the thread pool, in fact, too, but not the thread pool, but any pool, anything can pool, two words not said you have to take the thread pool,

CodePudding user response:

Actually this belongs to the "current limit" operation, the current limiting means a lot, pooling is just one of SemaphoreSlim is pooling control to realize the basic

Because I don't know the specific environment, we can search relevant product keyword in nuget RateLimiter

https://www.nuget.org/packages? Q=RateLimiter

If it is a webapi, nuget has achieved good call WebApiThrottle

CodePudding user response:

The client is a Windows service?? That is video file transfer between the server side, use socket travels? From already have to do is to control the number of connections, more than just refused to Accept, if the client disconnected, connect number minus 1. After the transfer, can also be active on the server disconnected, connect number minus 1.

CodePudding user response:

reference ying1234 reply: 3/f
client is a Windows service?? That is video file transfer between the server side, use socket travels? From already have to do is to control the number of connections, more than just refused to Accept, if the client disconnected, connect number minus 1. After the transfer, can also be active on the server disconnected, connect number minus 1.
not clear this socket,,, thank you, I go and have a look

CodePudding user response:

reference 1st floor wanghui0380 response:
SemaphoreSlim this good


As for the thread pool, in fact, too, but not the thread pool, but any pool, anything can pool, not say two words, you have to take the thread pool
thank you, but now this is the network environment, can not find the thing,,,

CodePudding user response:

reference ying1234 reply: 3/f
client is a Windows service?? That is video file transfer between the server side, use socket travels? From already have to do is to control the number of connections, more than just refused to Accept, if the client disconnected, connect number minus 1. After the transfer, can also be active on the server disconnected, connect number minus 1.
ah, is a way of communication, we use a webservice,,,

CodePudding user response:

Do the server restrictions, usually come with a Web server set, on the other hand, if manual writing services, Socket before starting the services can be set to receive the number of client connection.

CodePudding user response:

I write, if really just a limited quantity, using APPLICATION done at a draught, simple and convenient,
Complete a minus one, and that's it

CodePudding user response:

Thank you, now I write is with Interlocked in the lock. The Increment way limit an amount, don't know what to measure can not, I'll try the application, and see how
  •  Tags:  
  • C#
  • Related