12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- /*-------------------------------------------------------------------------
- * 功能描述:IdlingCommands
- * 作者:xulisong
- * 创建时间: 2019/1/3 17:22:01
- * 版本号:v1.0
- * -------------------------------------------------------------------------*/
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Autodesk.Revit.UI;
- namespace FWindSoft.Revit
- {
- /// <summary>
- /// 空闲命令消费者队列
- /// </summary>
- public class IdlingCommands
- {
- internal IdlingCommands()
- {
- Commands = new Queue<IdlingCommand>();
- }
- #region 生产消费队列维护
- /// <summary>
- /// 命令队列
- /// </summary>
- private readonly Queue<IdlingCommand> Commands;
- /// <summary>
- /// 在队列中加入command
- /// </summary>
- /// <param name="command"></param>
- public void Enqueue(IdlingCommand command)
- {
- lock (Commands)
- {
- Commands.Enqueue(command);
- }
- }
- /// <summary>
- /// 获取队列中的command
- /// </summary>
- /// <returns></returns>
- public IdlingCommand Dequeue()
- {
- IdlingCommand command = null;
- lock (Commands)
- {
- if (HasCommand)
- {
- command = Commands.Dequeue(); ;
- }
- }
- return command;
- }
- public bool HasCommand
- {
- get
- {
- return Commands.Count > 0;
- }
- }
- #endregion
- }
-
- }
|