Esempio n. 1
0
        /// <summary>
        /// 处理线程
        /// </summary>
        private void ThreadEntry()
        {
            try
            {
                while (true)
                {
                    _cacheSemaphore.WaitOne(_semephoreWatiTime);

                    List <TProduct> products = this.DequeueAll();

                    if (products.Count > 0)
                    {
                        ProductCreatedEventArgs <TProduct> args = new ProductCreatedEventArgs <TProduct>(products);
                        NotifyEvent(args);
                    }
                }
            }
            catch (System.Exception)
            {
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 通知事件
        /// </summary>
        private void NotifyEvent(ProductCreatedEventArgs <TProduct> args)
        {
            try
            {
                if (this.ProductCreated != null)
                {
                    var operators = this.ProductCreated.GetInvocationList();

                    foreach (var item in operators)
                    {
                        try
                        {
                            item.DynamicInvoke(this, args);
                        }
                        catch (System.Exception)
                        {
                        }
                    }
                }
            }
            catch (System.Exception)
            {
            }
        }