基本信息
源码名称:asp.net 异步进程监控
源码大小:0.33M
文件格式:.zip
开发语言:C#
更新时间:2017-11-05
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
可用于大文件上传 以及 需长时间执行的任务,可反馈出任务执行进度,如下图
可用于大文件上传 以及 需长时间执行的任务,可反馈出任务执行进度,如下图
#region Copyright © 2010-2011 Craig P Johnson [craigpj@gmail.com]
/*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the author(s) be held liable for any damages arising from
* the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not
* be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace AsyncProcessor
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ButtonStartAsynchProcess.Visible = true;
PanelProcessMonitor.Visible = false;
}
// add event handlers to execute after the process is complete
asyncProcessingMonitor1.ProcessingComplete = new EventHandler(ProcessingComplete);
asyncProcessingMonitor1.ProcessingError = new EventHandler(ProcessingError);
}
protected void ButtonStartAsynchProcess_Click(object sender, EventArgs e)
{
StartAsynchProcess();
PanelProcessMonitor.Visible = true;
}
private void StartAsynchProcess()
{
// generate a sudo random number for this process
// I suggest adding the process to a database and using teh unique id
// generated. that way you have a record of the process running
int seed = int.Parse(DateTime.Now.Ticks.ToString().Substring(0, 9));
int unique_proc_id = new Random(seed).Next();
// create a new AsyncProcessorDetail
AsyncProcessorDetail detail = new AsyncProcessorDetail(unique_proc_id, "c:\\path\\to\\your\\file", "filename", 0, "ProcessorExample", 1);
// call the AsyncProcessManager and pass it the AsyncProcessorDetail to be processed
AsyncProcessManager.StartAsyncProcess(detail);
// start the asyncProcessingMonitor control
asyncProcessingMonitor1.Start(unique_proc_id, true, "Default.aspx");
}
protected void ProcessingComplete(object sender, EventArgs e)
{
// execute any code here on processing complete
}
protected void ProcessingError(object sender, EventArgs e)
{
// display an error warning to your users
}
}
}