| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- /*******************************************************************************
- * 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
- {
- /// <summary>
- /// 扩展的窗口
- /// </summary>
- public partial class DKFormBase : FormBase
- {
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- protected DKFormBase()
- {
- InitializeComponent();
- }
- #endregion 构造函数
- #region 程序异步处理
- /// <summary>
- /// 窗体的异步处理
- /// </summary>
- /// <param name="method">异步方法</param>
- /// <returns></returns>
- public T DoAsync<T>(DKAsyncMethod<T> 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
- }
- }
|