示例#1
0
        public void ResumeWork()
        {
            var suspender = new Suspender();

            using (suspender.Suspend())
            {
            }
            suspender.IsSuspended.Should().BeFalse();
        }
示例#2
0
        public void SuspendWork()
        {
            var suspender = new Suspender();

            using (suspender.Suspend())
            {
                suspender.IsSuspended.Should().BeTrue();
            }
        }
示例#3
0
        public void MultiSuspend()
        {
            var suspender = new Suspender();

            using (suspender.Suspend())
            {
                using (suspender.Suspend())
                {
                }

                suspender.IsSuspended.Should().BeTrue();
            }
        }
示例#4
0
        public void ResumeWorkAfterException()
        {
            var suspender = new Suspender();

            try
            {
                using (suspender.Suspend())
                {
                    throw new Exception();
                }
            }
            catch (Exception) { }
            suspender.IsSuspended.Should().BeFalse();
        }
示例#5
0
        public ObservableQuery(IDataService db)
        {
            _db = db;
            H <ObservableQuery <T> > .Initialize(this);

            _timer       = NotifyHelper.EventHandlerService.GetTimer();
            _timer.Tick += async(a, b) => await _timer_TickAsync(a, b);

            _timer.Interval = TimeSpan.FromMilliseconds(300);

            Suspender = new Suspender(() => _timer.Stop(), () => _timer.Start());

            _token = Suspender.Get();
        }
        private void buttonRender_Click(object sender, System.EventArgs e)
        {
            if (!Root.AllValid)
            {
                MessageBox.Show("Layout invalid - please review your group/filter settings");
                return;
            }
            using (Suspender.ShowSandTimerAndSuspend(this))
            {
                Renderer.Padding            = (int)numericUpDownPadding.Value;
                Renderer.BoundingBox        = new Size((int)numericUpDownBBWidth.Value, (int)numericUpDownBBHeight.Value);
                Renderer.ScaleToBoundingBox = radioButtonScale.Checked;

                var img = Renderer.Render(Root) as Image;
                new ImagePreview(img).Show(this);
            }
        }
示例#7
0
 public SuspendableKeyedCollection(Func <TKey, TValue> itemCreator, Func <TValue, IDisposable> suspenderCreator)
 {
     if (itemCreator == null)
     {
         throw new ArgumentNullException("itemCreator");
     }
     if (suspenderCreator == null)
     {
         throw new ArgumentNullException("suspenderCreator");
     }
     this.itemCreator      = itemCreator;
     this.suspenderCreator = suspenderCreator;
     this.suspender        = new Suspender((Action)(() =>
     {
         KeyValuePair <TKey, IDisposable>[] keyValuePairArray = (KeyValuePair <TKey, IDisposable>[])null;
         lock (this.suspenderLock)
         {
             keyValuePairArray = this.notificationSuspenders.ToArray();
             this.notificationSuspenders.Clear();
         }
         if (keyValuePairArray == null)
         {
             return;
         }
         foreach (KeyValuePair <TKey, IDisposable> keyValuePair in keyValuePairArray)
         {
             keyValuePair.Value.Dispose();
         }
     }), (Action)(() =>
     {
         lock (this.suspenderLock)
         {
             foreach (KeyValuePair <TKey, TValue> item_1 in this.collection.ToArray())
             {
                 if ((object)item_1.Value != null && !this.notificationSuspenders.ContainsKey(item_1.Key))
                 {
                     this.notificationSuspenders.TryAdd(item_1.Key, this.suspenderCreator(item_1.Value));
                 }
             }
         }
     }));
 }