DKDockPanelBase.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:DKDockPanelBase.cs
  5. * 2.功能描述:扩展的窗口:单实例、异步共通处理等。
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2015/03/27 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Windows.Forms;
  12. using Dongke.IBOSS.PRD.Basics.BaseControls;
  13. using Dongke.IBOSS.PRD.Basics.BaseResources;
  14. using Dongke.IBOSS.PRD.Basics.DockPanel;
  15. using Dongke.IBOSS.PRD.WCF.DataModels;
  16. namespace Dongke.IBOSS.PRD.Client.Controls
  17. {
  18. /// <summary>
  19. /// 扩展的窗口
  20. /// </summary>
  21. public partial class DKDockPanelBase : DockPanelBase
  22. {
  23. #region 构造函数
  24. /// <summary>
  25. /// 构造函数
  26. /// </summary>
  27. protected DKDockPanelBase()
  28. {
  29. InitializeComponent();
  30. }
  31. #endregion 构造函数
  32. #region 程序异步处理
  33. /// <summary>
  34. /// 窗体的异步处理
  35. /// </summary>
  36. /// <param name="method">异步方法</param>
  37. /// <returns></returns>
  38. public T DoAsync<T>(DKAsyncMethod<T> method)
  39. {
  40. T result = default(T);
  41. try
  42. {
  43. this.StartProgress();
  44. IAsyncResult asyncResult = method.BeginInvoke(null, null);
  45. while (!asyncResult.IsCompleted)
  46. {
  47. Application.DoEvents();
  48. System.Threading.Thread.Sleep(1);
  49. }
  50. result = method.EndInvoke(asyncResult);
  51. }
  52. catch (Exception ex)
  53. {
  54. throw ex;
  55. }
  56. finally
  57. {
  58. this.EndProgress();
  59. if (result is ServiceResultEntity)
  60. {
  61. ServiceResultManager.Invoke(this, result as ServiceResultEntity);
  62. }
  63. }
  64. return result;
  65. }
  66. #endregion
  67. }
  68. }