Exemple #1
0
 public void UpdateValues()
 {
     framesleft--;
     if (framesleft <= 0.0)
     {
         if (waitHandle != null)
         {
             waitHandle.Set();
             waitHandle = null;
         }
     }
 }
Exemple #2
0
 public void Update()
 {
     if (timeleft != null)
     {
         if (timeleft != TimeSpan.MinValue)
         {
             timeleft -= TimeSpan.FromSeconds(1.0 / 60.0);
         }
         if (timeleft <= TimeSpan.Zero)
         {
             timeleft = null;
             waitHandle.Set();
         }
     }
 }
Exemple #3
0
 public void Init(CommandDelegate command, TimeSpan delay)
 {
     Cancel();
     if (delay != TimeSpan.MinValue)
     {
         Delay = delay;
     }
     _timer = new Timer(o => {
         if (IsRunning)
         {
             return;
         }
         TimerErrorException tex = null;
         try {
             WaitHandler.Reset();
             IsRunning = true;
             command();
             if (_period == infinity)
             {
                 Cancel();
             }
         } catch (Exception exc) {
             if (Error != null)
             {
                 Error(this, tex = new TimerErrorException(exc));
             }
         } finally {
             IsRunning = false;
             try {
                 WaitHandler.Set();
             } catch { }
             if (tex == null || !tex.CancelFinishedEvent)
             {
                 RaiseFinished();
             }
         }
     },
                        null, Delay, _period);
 }
        protected override void JobThread(CancellationToken token)
        {
            var position = 0;

            while (_nextCheck.IsNext(position))
            {
                token.ThrowIfCancellationRequested();

                var readingPart = _queue.Next();
                if (readingPart == null)
                {
                    WaitHandler.WaitOne();
                    continue;
                }

                WaitHandler.Set();

                var bytes = readingPart.Data;
                _writer.Write(bytes);

                position++;
            }
        }
Exemple #5
0
        protected override void JobThread(CancellationToken token)
        {
            var index = 0;

            while (Reader.LeftBytes > 0)
            {
                token.ThrowIfCancellationRequested();

                if (_queue.Count() > Settings.ThreadPoolSize)
                {
                    WaitHandler.WaitOne();
                    continue;
                }

                WaitHandler.Set();

                var bytes = Read();
                _queue.Add(index, bytes);

                index++;
            }

            _count = index;
        }
 public void SetError(string error)
 {
     IsError      = true;
     ErrorMessage = error;
     WaitHandler.Set();
 }
 public void SetResponse(object response)
 {
     Response = response;
     WaitHandler.Set();
 }
 protected override void WhenChannelShutdown(object sender, ShutdownEventArgs reason)
 {
     base.WhenChannelShutdown(sender, reason);
     WaitHandler.Set();
 }
 internal protected override void DoAck(BasicDeliverEventArgs basicDeliverEventArgs, IBasicConsumer subscriptionInfo)
 {
     base.DoAck(basicDeliverEventArgs, subscriptionInfo);
     WaitHandler.Set();
 }
 protected override void WhenChannelShutdown(IModel model, ShutdownEventArgs reason)
 {
     base.WhenChannelShutdown(model, reason);
     WaitHandler.Set();
 }
 protected override void DoAck(RabbitMQ.Client.Events.BasicDeliverEventArgs basicDeliverEventArgs, IBasicConsumer subscriptionInfo)
 {
     base.DoAck(basicDeliverEventArgs, subscriptionInfo);
     WaitHandler.Set();
 }