using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
namespace RevitTools.Utils.Revit
{
///
/// 外部事件处理程序
///
public class ExEventHandle : IExternalEventHandler
{
///
/// 创建具有指定名字的外部事件处理程序
///
///
public ExEventHandle(string name)
{
this.name = name;
}
private readonly string name;
///
/// 工作项队列
///
internal readonly ConcurrentQueue ExEventQueue = new ConcurrentQueue();
///
/// 执行外部事件函数
///
///
public void Execute(UIApplication app)
{
while (ExEventQueue.TryDequeue(out ExEventWorkItem workItem))
{
workItem.InvokeAction(app);
}
}
///
/// 获取字符串标识
///
///
public string GetName()
{
return name;
}
}
}