Decrease download speed in DownloadFileAsync RRS feed

  • Question

  • This is my code:

    using var client = new WebClient();
    client.DownloadFileAsync(new Uri(""), "10GB.bin");

    All I want is, when another user connects to the modem / router via wifi and starts listening music on Spotify or another usages, which need bandwidth, the method DownloadFileAsync decreases download speed until he/she is using bandwidth and increase it again when nobody is using bandwidth for a period.

    Tuesday, February 4, 2020 6:30 AM

All replies

  • You need specialized class to do this.

    See this thread to two CodeProject page for example.

    Tuesday, February 4, 2020 7:16 AM
  • I've read that, but how can I detect that bandwidth is using by another users to applying bandwidth throttling? I don't want to apply bandwidth throttling when no users are using internet.
    Tuesday, February 4, 2020 2:43 PM
  • The strategy in the first link is to tag your network packets with low priority (by marking the TOS/DS fields in IP packet header), so if your router supports QOS (My less-than-HKD100 hub at home have it, the ports will be labeled with "QOS"), it'll allow other packets with normal priority to go at higher rate when it sees both.

    When there is no other higher priority packets, your application's network packet will travel at normal speed.


    The second link is just a downloader which allow you to limit the max speed it can use, so does not have the effect you want.


    On a second thought, since my Netgear router itself have QOS settings that allows you to set priority by protocol and port numbers, maybe you check the router settings page for something like that. If that exist, you need not meddle your code at all and can regulate traffics for your "other users" as well.

    Tuesday, February 4, 2020 3:30 PM
  • It's better to explain otherwise. Yesterday, when I wanted to open a website, it was loading very lately. It was because at that time, my download manager (IDM) was downloading a big file and it was using all bandwidth. So I had to open it and reduce download speed manually, according bellow picture:

    Then, suddenly I got this idea that build a new download manager so that whenever me, or other users on the LAN network (or WiFi) want to use internet, the maximum download speed decreases and when nobody are using internet, my download manager increase download speed. I don't even know if it's possible or not.

    What is your opinion?

    Tuesday, February 4, 2020 4:41 PM
  • If your router supports QOS settings, just go there and reduce the priority of "WWW" or specific host(s) and you'll be okay.
    Wednesday, February 5, 2020 12:32 AM
  • You didn't realize what I'm saying. I don't want to solve this problem for myself. I'm building a new download manager and I want to publish it in the internet, and I want my users without any technical information can use it. Simply put, In above picture I want to add new checkbox named "Automatically reduce maximum download speed, when you are using internet".  I'm a developer and here is not superuser community.
    Wednesday, February 5, 2020 7:03 AM
  • Okay. You can refer to this thread for how to get the "bytes received" and "speed". Then use this formula to calculate the network utilization.

    However there is problem because think about "what happen when two program does that". I still think the QOS style "just tag it and let firmware decide" or even "just let the router decided" is better solution. Of course "just tag it and let firmware decide" has it's problem because the API is designed for use in C++ and very difficult to find complete guide on how to implement it in C#.

    Wednesday, February 5, 2020 8:33 AM
  • Hi,

    Has your problem been solved?

    If so, please click "Mark as answer" to the appropriate answer, so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Wednesday, March 4, 2020 8:26 AM