Skip to content

Instantly share code, notes, and snippets.

@takwai
Created October 23, 2014 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takwai/871c59d9112133d2390c to your computer and use it in GitHub Desktop.
Save takwai/871c59d9112133d2390c to your computer and use it in GitHub Desktop.
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