Beispiel #1
0
        /// <summary>执行工作</summary>
        public static void Work()
        {
            while (true)
            {
                MyFileInfo fileinfo = null;
                lock (_locker)
                {
                    if (_tasks.Count > 0)
                    {
                        fileinfo = _tasks.Dequeue(); // 有任务时,出列任务

                        if (fileinfo == null)        // 退出机制:当遇见一个null任务时,代表任务结束
                        {
                            return;
                        }
                    }
                }

                if (fileinfo != null)
                {
                    Log.logger.Info("Loading " + fileinfo.FullPath);
                    Convert.Invoke(fileinfo);
                }
                else
                {
                    _wh.WaitOne();   // 没有任务了,等待信号
                    Log.logger.Info("Waiting .....");
                }
            }
        }
Beispiel #2
0
        /// <summary>插入任务</summary>
        public static void EnqueueTask(string filename)
        {
            lock (_locker)
            {
                MyFileInfo fileInfo = new MyFileInfo(filename);
                _tasks.Enqueue(fileInfo);  // 向队列中插入任务
            }

            _wh.Set();  // 给工作线程发信号
        }
Beispiel #3
0
        public static void Invoke(MyFileInfo myFileInfo)
        {
            Autodesk.Navisworks.Api.View activeView = Autodesk.Navisworks.Api.Application.ActiveDocument.ActiveView;
            var doc = Autodesk.Navisworks.Api.Application.ActiveDocument;


            if (doc.TryOpenFile(myFileInfo.FullPath))
            {
                NavReader navReader = new NavReader(doc);
                navReader.Execute();
            }
        }