Created
October 23, 2014 16:55
-
-
Save takwai/871c59d9112133d2390c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using System.Threading; | |
namespace ConsoleApplication2 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
new Thread(() => { new Downloader().Exceute(); }).Start(); | |
new Thread(() => { new Downloader().Exceute(); }).Start(); | |
Console.ReadLine(); | |
} | |
} | |
class Downloader | |
{ | |
private long filename = DateTime.Now.Ticks; | |
public void Exceute() | |
{ | |
var p = new Process(); | |
p.StartInfo.FileName = @"D:\curl.exe"; | |
p.StartInfo.Arguments = string.Format("-o D:\\{0}.exe http://dldir1.qq.com/qqfile/qqvideo/QQVideoDesktop1.0final.exe", filename); | |
p.StartInfo.CreateNoWindow = true; | |
p.StartInfo.UseShellExecute = false; | |
p.StartInfo.RedirectStandardError = true; | |
p.ErrorDataReceived += p_ErrorDataReceived; | |
p.Start(); | |
p.BeginErrorReadLine(); | |
p.WaitForExit(); | |
} | |
void p_ErrorDataReceived(object sender, DataReceivedEventArgs e) | |
{ | |
string data = e.Data; | |
if (e.Data != null && !data.Contains("Total")) | |
{ | |
var source = data.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); | |
if (source.Length > 0) | |
Console.WriteLine("{3}\t{0}%\t{1}/{2}", source[0], source[3], source[1], filename); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment