| |

VerySource

 Forgot password?
 Register
Search
View: 8|Reply: 8

Multi-threaded download issues

[Copy link]

1

Threads

3

Posts

3

Credits

Newbie

Rank: 1

Credits
3

 China

Post time: 2020-3-22 12:30:01
| Show all posts |Read mode
The program has 5 download threads, each download thread downloads different resources, but it can only support up to two download threads. When the third download thread starts, the system will crash. Is there any way to solve it?
Reply

Use magic Report

0

Threads

104

Posts

56

Credits

Newbie

Rank: 1

Credits
56

 China

Post time: 2020-6-30 10:30:02
| Show all posts
It should not be the reason for the limitation of the number of threads, it should be other reasons!
I do not know how your program?
Reply

Use magic Report

0

Threads

6

Posts

6

Credits

Newbie

Rank: 1

Credits
6

 United States

Post time: 2020-6-30 14:15:01
| Show all posts
The thread itself will not have this problem, upstairs
Reply

Use magic Report

0

Threads

95

Posts

56

Credits

Newbie

Rank: 1

Credits
56

 China

Post time: 2020-6-30 18:15:01
| Show all posts
Can only support up to two threads?

It's not possible...
Reply

Use magic Report

0

Threads

95

Posts

56

Credits

Newbie

Rank: 1

Credits
56

 China

Post time: 2020-6-30 18:45:01
| Show all posts
TO: The system will crash when the third download thread starts

What do you mean by a system crash?
Reply

Use magic Report

0

Threads

3

Posts

4

Credits

Newbie

Rank: 1

Credits
4

 China

Post time: 2020-6-30 20:15:01
| Show all posts
It should not be, this download is precedent
Reply

Use magic Report

1

Threads

3

Posts

3

Credits

Newbie

Rank: 1

Credits
3

 China

 Author| Post time: 2020-7-17 17:15:01
| Show all posts
private WebRequest httpRequest;
        private WebResponse httpResponse;
        private byte[] buffer;
        private Thread downloadThread;
        Stream ns;
        private FileStream fs;
        private long length;
        private long downlength = 0;
        private long lastlength = 0;
        public delegate void updateData(string value); //Set the delegate to update the main interface
        private int totalseconds = 0; //total time
        private updateData UIDel;
        private string filename = @"d:\sybaohj.wmv";
        private int DownLoadNumber = 0; //File download count

private void downloadFile()
        {
            ns = httpResponse.GetResponseStream();

            int i;
            UIDel = new updateData(updateUI);
            while ((i = ns.Read(buffer, 0, buffer.Length))> 0)
            {

                downlength += i;
                string value = downlength.ToString();
                this.Invoke(UIDel, value);
                fs.Write(buffer, 0, i);
            }
            speedlabel1.Text = "Download complete";
        }
        /* private void show()
         {
             UIDel = new updateData(updateUI);
             int value = 0;
             while (value <= 100)
             {
                 this.progressBar1.Value = value;
                 value++;
             }
         }*/
        void updateUI(string value)
        {
            this.lensthlabel1.Text = "Download size:"+value;
            this.progressBar1.Value = Int32.Parse(value);
        }

Download the code and enter ``crash is that the system is not responding'' and it will not automatically shut down and exit
Reply

Use magic Report

1

Threads

3

Posts

3

Credits

Newbie

Rank: 1

Credits
3

 China

 Author| Post time: 2020-7-17 17:30:01
| Show all posts
I searched with Baidu, ```found a friend and I have the same problem,'' the code is really okay```, but I don’t know why the thread exceeds 3 programs, it will not respond```I used to make 255 threads This problem has never occurred.
Reply

Use magic Report

0

Threads

1

Posts

2

Credits

Newbie

Rank: 1

Credits
2

 China

Post time: Yesterday 09:00
| Show all posts
Single CPU? Is the CPU occupied?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2020|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list