Abdelrahman Saeed
Abdelrahman Saeed

Reputation: 81

How to limit number of opened downloads for a specific file on server?

I have a WCF service hosted on a server and another console application on multiple clients. Each console application send a request to download a specific file on server and I want to check how many downloads are currently active if more than 4 I want the WCF to deny the request if less then send the file. I don't know what is the best solution to detect the number of active downloads.

Upvotes: 0

Views: 73

Answers (1)

Ricardo Pontual
Ricardo Pontual

Reputation: 3757

You can use Service Throttling of WCF. It can limit the number of concurrent calls:

serviceThrottling at MSDN

You can also program your own control, marking the service as Single, like this:

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]

And control the number of files with a static variable. It's not so clear but works.

Upvotes: 2

Related Questions