注册本站  论坛  繁體中文

电脑技巧
手机 | MP3 | MP4 | 显卡 | 主板 | 显示器 | 光存储 | 笔记本 | 网络设备 | 移动存储 | 数码相机
键鼠 | CPU | 音箱 | GPS | 电视 | 服务器 | 投影机 | 机箱电源 | 品牌电脑 | 办公打印 |
| 网站首页 | Cisco | Windows | Linux | Java | Dotnet | Oracle | 网页设计 | 平面设计 | 安全 | 软件应用 | 电脑维修 | 办公维修 |
您现在的位置: 电脑技巧 >> Dotnet >> C# >> Dotnet正文

c#中重定向windows控制台程序的输出信息

文章来源:中国IT实验室收集整理 作者:佚名 更新时间:2008-5-25 3:56:13 【 】 【加入收藏

这个问题来自社区提问,代码保留一份用来以后回答

using System;
using System.ComponentModel;
using System.Windows.Forms;
namespace WindowsApplication4
...{
/**////


/// gui 类
///

public partial class Form1 : Form
...{
public Form1()
...{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
...{
//用子线程工作
new System.Threading.Thread(new System.Threading.ThreadStart(StartDownload))

.Start();
}
//开始下载
public void StartDownload()
...{
Downloader downloader = new Downloader();
downloader.onDownLoadProgress += new Downloader.dDownloadProgress(downloader_

onDownLoadProgress);
downloader.Start();
}
//同步更新ui
void downloader_onDownLoadProgress(long total, long current)
...{
if (this.InvokeRequired)
...{
this.Invoke(new Downloader.dDownloadProgress(downloader_onDownLoadProgress),

new object[] ...{ total, current });
}
else
...{
this.progressBar1.Maximum = (int)total;
this.progressBar1.Value = (int)current;
}
}
}

/**////


/// 下载类
///

public class Downloader
...{
//委托
public delegate void dDownloadProgress(long total,long current);
//事件
public event dDownloadProgress onDownLoadProgress;
//开始模拟工作
public void Start()
...{
for (int i = 0; i < 100; i++)
...{
if (onDownLoadProgress != null)
onDownLoadProgress(100, i);
System.Threading.Thread.Sleep(100);
}
}
}
}

  • 上一篇Dotnet:

  • 下一篇Dotnet:
  • 最 新 热 门
     asp根据表单自动生成sql语句的函数
     ASP教程:自己写的数据库操作类
     ASP处理多关键词查询实例代码
     asp文件打不开的原因
     IIS7.0在Vista系统下安装注意事项
     XMLHTTP Post Form时的表单乱码
     xmlhttp是如何完成异步操作的
     VB.Net处理MySQL中二进制问题
     VB.NET的常量与枚举学习
     VB.NET字符数据类型和其他数据类型
    最 新 推 荐
     运用设计模式构建通用数据库访问类
     C#中使用钩子控制鼠标实现代码
     C#打开SolidWorks2008零件文件
     C# 实现屏幕键盘 (ScreenKeyboard)
     C#发现之旅第二讲_C#-XSLT开发
     C#数字格式化输出
     C#中通过API调用获取文件图标
     C#中一套生成sql条件的类
     C#汉字转拼音功能类
     DataGridView的常用用法
    相 关 文 章

    C#中使用钩子控制鼠标实现代码
    C#打开SolidWorks2008零件文件
    C# 实现屏幕键盘 (ScreenKeyboard)
    C#发现之旅第二讲_C#-XSLT开发
    C#数字格式化输出
    C#中通过API调用获取文件图标
    C#中一套生成sql条件的类
    C#汉字转拼音功能类
    C#基础入门学习笔记
    C#正则表达式快速入门

    | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 网站公告

     

    Copyright 2006-2008 pcjx.com All Rights Reserved
    电脑技巧 版权所有 粤ICP备06059145号 地图
    本网站所有内容未经许可不得转载或做其他使用