Open hlm750908 opened 3 years ago
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms;
namespace WindowsFormsApp6 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void Form1_Load(object sender, EventArgs e)
{
progressBar1.Minimum = 0;
progressBar1.Maximum = 100;
}
private void button1_Click(object sender, EventArgs e)
{
Thread th1 = new Thread(new ThreadStart(go));
th1.Start();
}
void ok(string str)
{
button1.Text = str;
}
void setNow(int i)
{
progressBar1.Value = i;
}
private void go()
{
var dq = new DownloadQueue.DownloadQueue();
var task = dq.MakeDefault("http://47.101.152.47:8088/softupdate/updatetest/d78cef254b0beac670cc02594323d7ff.rar");
task.StartCallback = () =>
{
button1.Invoke(new Action<string>(ok), "Download Start");
};
long total = 0;
long current = 0;
task.SizeCallback = (size) => { Console.WriteLine("Total File Size: " + size); total = size; };
task.DownloadCallback = (size) =>
{
current += size;
Console.WriteLine("Receive: " + size + " " + (current / (double)total));
progressBar1.Invoke(new Action<int>(setNow), (int)((current / (double)total) * 100));
};
task.Filename = "test.rar";
dq.DownloadFile(task);
dq.Dispose();
}
}
}
Hello! Your library works very well, but can you write a winForm demo and put it up? Sorry I can't multithread Thank you very much!