コード例 #1
0
 void onEndReachedEvent(CurvySplineMoveEventArgs e)
 {
     if (!(_active == this))
     {
         return;
     }
     if (e.Spline && e.Spline != Spline)
     {
         e.Spline.OnMoveEndReached.RemoveListener(onEndReachedEvent);
     }
     else
     {
         e.Sender = this;
         OnEndReached.Invoke(e);
     }
 }
コード例 #2
0
        /// <summary>
        /// Start automatically consuming message and trigger events.
        ///
        /// Will invoke OnMessage, OnEndReached and OnConsumerError events.
        /// </summary>
        public void Start()
        {
            if (consumerTask != null)
            {
                throw new InvalidOperationException("Consumer task already running");
            }

            consumerCts = new CancellationTokenSource();
            var ct = consumerCts.Token;

            consumerTask = Task.Factory.StartNew(() =>
            {
                while (!ct.IsCancellationRequested)
                {
                    var messageAndError = Consume(TimeSpan.FromSeconds(1));
                    if (messageAndError.HasValue)
                    {
                        var mae = messageAndError.Value;
                        if (mae.Error == ErrorCode.NO_ERROR)
                        {
                            OnMessage?.Invoke(this, mae.Message);
                        }
                        else if (mae.Error == ErrorCode._PARTITION_EOF)
                        {
                            OnEndReached?.Invoke(this,
                                                 new TopicPartitionOffset()
                            {
                                Topic     = mae.Message.Topic,
                                Partition = mae.Message.Partition,
                                Offset    = mae.Message.Offset,
                            });
                        }
                        else
                        {
                            OnConsumerError?.Invoke(this, mae.Error);
                        }
                    }
                }
            }, ct, TaskCreationOptions.LongRunning, TaskScheduler.Default);
        }
コード例 #3
0
 private void EmOnOnEndReached()
 {
     OnEndReached?.Invoke();
 }
コード例 #4
0
 private void Instance_MediaEnded(object sender, RoutedEventArgs e)
 {
     OnEndReached?.Invoke();
     OnStopped?.Invoke(this);
 }
コード例 #5
0
 private void EndReached(object sender, EventArgs e)
 {
     OnEndReached?.Invoke();
     _appWebServer.OnEndReached?.Invoke();
 }