![](https://csdnimg.cn/release/download_crawler_static/4005507/bg6.jpg)
using System.Collections.Generic;
using System.Threading;
using System.Workflow.Runtime;
namespace Nocturne.Workflow.Hosting
{
/// <summary>
/// 工作流实例的容器
/// </summary>
[Serializable]
public class WorkflowInstanceWrapper
{
private WorkflowInstance _workflowInstance;
private ManualResetEvent _waitHandle = new ManualResetEvent(false);
private Dictionary<string, object> _outputParameters = new Dictionary<string, object>();
private Exception _exception;
private string _reasonSuspended = string.Empty;
public WorkflowInstanceWrapper(WorkflowInstance instance)
{ _workflowInstance = instance; }
#region 公开属性与方法
/// <summary>
/// 获取工作流实例的 ID
/// </summary>
public Guid Id
{
get
{
if (_workflowInstance != null) { return _workflowInstance.InstanceId; }
else { return Guid.Empty; }
}
}
/// <summary>
/// 输出参数的集合
/// </summary>
public Dictionary<string, object> OutputParameters
{ get { return _outputParameters; } set { _outputParameters = value; } }
/// <summary>
/// 一个等待句柄。宿主应用程序可以使用它,挂起
/// 进程直到工作流完成。
/// </summary>
public ManualResetEvent WaitHandle
{ get { return _waitHandle; } set { _waitHandle = value; } }
/// <summary>
/// 工作流可能抛出的异常对象
/// </summary>
public Exception Exception
{ get { return _exception; } set { _exception = value; } }
/// <summary>
/// 工作流挂起的原因
/// /// </summary>
public string ReasonSuspended
{ get { return _reasonSuspended; } set { _reasonSuspended = value; } }
/// <summary>
/// 真实的工作流实例
/// </summary>
public WorkflowInstance WorkflowInstance