/*******************************************************************************
* Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:DKFormBase.cs
* 2.功能描述:扩展的窗口:单实例、异步共通处理等。
* 编辑履历:
* 作者 日期 版本 修改内容
* 陈晓野 2015/03/27 1.00 新建
*******************************************************************************/
using System;
using System.Windows.Forms;
using Dongke.IBOSS.PRD.Basics.BaseControls;
using Dongke.IBOSS.PRD.Basics.BaseResources;
using Dongke.IBOSS.PRD.WCF.DataModels;
namespace Dongke.IBOSS.PRD.Client.Controls
{
///
/// 扩展的窗口
///
public partial class DKFormBase : FormBase
{
#region 构造函数
///
/// 构造函数
///
protected DKFormBase()
{
InitializeComponent();
}
#endregion 构造函数
#region 程序异步处理
///
/// 窗体的异步处理
///
/// 异步方法
///
public T DoAsync(DKAsyncMethod method)
{
T result = default(T);
try
{
this.StartProgress();
IAsyncResult asyncResult = method.BeginInvoke(null, null);
while (!asyncResult.IsCompleted)
{
Application.DoEvents();
System.Threading.Thread.Sleep(1);
}
result = method.EndInvoke(asyncResult);
}
catch (Exception ex)
{
throw ex;
}
finally
{
this.EndProgress();
if (result is ServiceResultEntity)
{
ServiceResultManager.Invoke(this, result as ServiceResultEntity);
}
}
return result;
}
#endregion
}
}