コード例 #1
0
ファイル: Counter.cs プロジェクト: TheeEmuu/School
    public void Add(int x)
    {
        total += x;

        if (total >= threshold)
        {
            ThresholdReachedEventArgs args = new ThresholdReachedEventArgs();
            args.Threshold   = threshold;
            args.TimeReached = DateTime.Now;
            OnThresholdReached(args);
        }
    }
コード例 #2
0
        protected virtual void OnThresholdReached(ThresholdReachedEventArgs e)
        {
            // Make a temporary copy of the event to avoid possibility of a race condition
            EventHandler <ThresholdReachedEventArgs> handler = ThresholdReached;

            if (handler != null)
            {
                Console.WriteLine("Before handler");
                handler(this, e);
                Console.WriteLine("After handler");
            }
        }
コード例 #3
0
        protected void IncrementBuilder(MouseEventArgs arg, metrics def)
        {
            Thresholdcounter += 1;
            Console.WriteLine($"invoked threshold {def.Name}, {def.klasa}, {arg.ClientX}, {arg.ClientY}");
            ThresholdReachedEventArgs args = new ThresholdReachedEventArgs();

            args.Threshold   = Thresholdcounter;
            args.TimeReached = DateTime.Now;
            args.Name        = def.Name;
            if (ThresholdcounterTotal <= Thresholdcounter)
            {
                OnThresholdReached(args);
            }
        }
コード例 #4
0
            public void Add(int x)
            {
                total += x;
                if (total >= threshold)
                {
                    ThresholdReachedEventArgs eventArgs = new ThresholdReachedEventArgs()
                    {
                        Threshold   = threshold,
                        Value       = total,
                        TimeReached = DateTime.UtcNow
                    };

                    OnThresholdReached(eventArgs);
                }
            }
コード例 #5
0
        public void Add(int x)
        {
            total += x;
            if (total >= threshold)
            {
                ThresholdReachedEventArgs env = new ThresholdReachedEventArgs();

                env.Threshold   = threshold;
                env.TimeReached = DateTime.Now;


                // raise the event
                OnThresholdReached(env);
            }
        }
コード例 #6
0
            public void DriverStart()
            {
                new Thread(() =>
                {
                    total += 1;

                    if (total >= threshold)
                    {
                        ThresholdReachedEventArgs args = new ThresholdReachedEventArgs();
                        args.Threshold = threshold;
                        OnThresholdeReached(args);
                    }

                    Thread.Sleep(20);

                }).Start();
            }
コード例 #7
0
        private static void LogEntry_OnReadLogEnd(object sender, ThresholdReachedEventArgs e)
        {
            try
            {
                Console.WriteLine("################ Events for " + e.EventLogName);
                if (!Directory.Exists(".\\logs\\"))
                {
                    Directory.CreateDirectory(".\\logs\\");
                }
                String fName = DateTime.Now.ToString("yyyy-MM-dd_HH_") + Path.GetFileName(e.EventLogName);

                String fpath = String.Format("{0}\\{1}", ".\\logs", fName.Replace('%', '0'));
                Console.WriteLine("1 " + fpath);
                fpath = Path.ChangeExtension(fpath, ".xml");

                Console.WriteLine("Output to: " + fpath);
                StringBuilder strb = new StringBuilder();
                int           cnt  = 0;
                e.NormalisedEvents.ForEach((s) =>
                {
                    //        Console.WriteLine((s as EventRecord).ToXml());
                    strb.AppendLine((s as EventRecord).ToXml());
                    cnt++;
                    if (cnt > 100)
                    {
                        File.AppendAllText(fpath, strb.ToString());
                        strb = new StringBuilder();
                        cnt  = 0;
                    }
                });
                if (cnt > 0)
                {
                    File.AppendAllText(fpath, strb.ToString());
                }

                Console.WriteLine("################ Events for " + e.EventLogName + " ######## end #### ");
            }catch (Exception ex)
            {
                Console.WriteLine(e.EventLogName + " " + "error " + ex.Message);
            }
        }
コード例 #8
0
 private static void Raiser_ThresholdReached(object sender, ThresholdReachedEventArgs e)
 {
     Const.OpcDatasource.CoalOnBelt = false;
 }
コード例 #9
0
ファイル: Subscriber.cs プロジェクト: PESPESPES/Directorios
 // Define what actions to take when the event is raised.
 void HandleCustomEvent(object sender, ThresholdReachedEventArgs e)
 {
     Console.WriteLine(id + " received this message: {0}", e.ErrorDescription);
 }
コード例 #10
0
 /// <summary>
 /// 超时未接收数据后引发的事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Raiser_ThresholdReached(object sender, ThresholdReachedEventArgs e)
 {
     this.GnssInfo.Working = false;
 }
コード例 #11
0
ファイル: PriceMoniter.cs プロジェクト: realstartca/meng-test
        public void SetPrice(double price)
        {
            try
            {
                // Check BuyTrigger
                if (BuyTrigger != null && BuyTrigger.Threshold != null)
                {
                    // If price rises
                    if (price > _price)
                    {
                        if (price >= BuyTrigger.Threshold && BuyTrigger.TriggerDirection != TriggerDirectionEnum.Drop)
                        {
                            bool shouldTrigger = true;

                            // if fluctuations less than Sensitivity value, do not send notification
                            if (BuyTrigger.LastNotificationPrice != null && Math.Abs(price - Convert.ToDouble(BuyTrigger.LastNotificationPrice)) < Math.Abs(BuyTrigger.Sensitivity))
                            {
                                shouldTrigger = false;
                            }

                            if (shouldTrigger)
                            {
                                // Send BuyTrigger notificaiton
                                ThresholdReachedEventArgs args = new ThresholdReachedEventArgs();
                                args.Threshold   = Convert.ToDouble(BuyTrigger.Threshold);
                                args.Price       = price;
                                args.TimeReached = DateTime.Now;
                                BuyTrigger.OnTriggerThresholdReached(args);
                                BuyTrigger.LastNotificationPrice = price;
                            }
                        }
                    }
                    // If price drops
                    else if (price < _price && price <= BuyTrigger.Threshold && BuyTrigger.TriggerDirection != TriggerDirectionEnum.Rise)
                    {
                        bool shouldTrigger = true;

                        // if fluctuations less than Sensitivity value, do not send notification
                        if (BuyTrigger.LastNotificationPrice != null && Math.Abs(price - Convert.ToDouble(BuyTrigger.LastNotificationPrice)) < Math.Abs(BuyTrigger.Sensitivity))
                        {
                            shouldTrigger = false;
                        }

                        if (shouldTrigger)
                        {
                            // Send BuyTrigger notificaiton
                            ThresholdReachedEventArgs args = new ThresholdReachedEventArgs();
                            args.Threshold   = Convert.ToDouble(BuyTrigger.Threshold);
                            args.Price       = price;
                            args.TimeReached = DateTime.Now;
                            BuyTrigger.OnTriggerThresholdReached(args);
                            BuyTrigger.LastNotificationPrice = price;
                        }
                    }
                }

                // Check Sell Trigger
                if (SellTrigger != null && SellTrigger.Threshold != null)
                {
                    // If price rises
                    if (price > _price)
                    {
                        if (price >= SellTrigger.Threshold && SellTrigger.TriggerDirection != TriggerDirectionEnum.Drop)
                        {
                            bool shouldTrigger = true;

                            // if fluctuations less than Sensitivity value, do not send notification
                            if (SellTrigger.LastNotificationPrice != null && Math.Abs(price - Convert.ToDouble(SellTrigger.LastNotificationPrice)) < Math.Abs(SellTrigger.Sensitivity))
                            {
                                shouldTrigger = false;
                            }

                            if (shouldTrigger)
                            {
                                // Send SellTrigger notificaiton
                                ThresholdReachedEventArgs args = new ThresholdReachedEventArgs();
                                args.Threshold   = Convert.ToDouble(SellTrigger.Threshold);
                                args.Price       = price;
                                args.TimeReached = DateTime.Now;
                                SellTrigger.OnTriggerThresholdReached(args);
                                SellTrigger.LastNotificationPrice = price;
                            }
                        }
                    }
                    // If price drops
                    else if (price < _price && price <= SellTrigger.Threshold && SellTrigger.TriggerDirection != TriggerDirectionEnum.Rise)
                    {
                        bool shouldTrigger = true;

                        // if fluctuations less than Sensitivity value, do not send notification
                        if (SellTrigger.LastNotificationPrice != null && Math.Abs(price - Convert.ToDouble(SellTrigger.LastNotificationPrice)) < Math.Abs(SellTrigger.Sensitivity))
                        {
                            shouldTrigger = false;
                        }

                        if (shouldTrigger)
                        {
                            // Send SellTrigger notificaiton
                            ThresholdReachedEventArgs args = new ThresholdReachedEventArgs();
                            args.Threshold   = Convert.ToDouble(SellTrigger.Threshold);
                            args.Price       = price;
                            args.TimeReached = DateTime.Now;
                            SellTrigger.OnTriggerThresholdReached(args);
                            SellTrigger.LastNotificationPrice = price;
                        }
                    }
                }
            }
            catch
            {
                // Log Error
            }

            _price = price;
        }
コード例 #12
0
 private void Raiser_ThresholdReached(object sender, ThresholdReachedEventArgs e)
 {
     //接收超时的处理方法
 }
コード例 #13
0
ファイル: Instrument.cs プロジェクト: jpgithub/jprepost
 protected virtual void OnThresholdeReached(ThresholdReachedEventArgs e)
 {
     EventHandler<ThresholdReachedEventArgs> handler = ThresholdReached;
     if (handler != null)
     {
         handler(this, e);
     }
 }
コード例 #14
0
ファイル: Instrument.cs プロジェクト: jpgithub/jprepost
            public void DriverStart()
            {
                new Thread(() =>
                {
                    total += 1;

                    if (total >= threshold)
                    {
                        ThresholdReachedEventArgs args = new ThresholdReachedEventArgs();
                        args.Threshold = threshold;
                        OnThresholdeReached(args);
                    }

                    Thread.Sleep(20);

                }).Start();
            }
コード例 #15
0
 static void c_ThresholdReached(object sender, ThresholdReachedEventArgs e)
 {
     Console.WriteLine("The threshold of {0} was reached at {1}.", e.Threshold, e.TimeReached);
 }
コード例 #16
0
 protected virtual void OnThresholdReached(ThresholdReachedEventArgs e)
 {
     this.ThresholdReached?.Invoke(this, e);
 }
コード例 #17
0
 private void c_ThresholdReached(object sender, ThresholdReachedEventArgs e)
 {
     Console.WriteLine("The threshold of {0} was reached at {1} by {2}.", e.Threshold, e.TimeReached, e.Name);
     electronicDisplayer = BuildSVG_displayer((int)Math.Floor((double)SVG.width / ((e.Name == "secondhand") ? 8 : 6)), (int)(0.35 * (double)SVG.height), (e.Name == "secondhand") ? "WWWOOOWWW" : "Boom!!!");
     Thresholdcounter    = 0;
 }
コード例 #18
0
ファイル: Counter.cs プロジェクト: TheeEmuu/School
 static void c_ThresholdReached(object sender, ThresholdReachedEventArgs e)
 {
     Console.WriteLine("The threshold of {0} was reached at {1}.", e.Threshold, e.TimeReached);
     Environment.Exit(0);
 }
コード例 #19
0
ファイル: Program.cs プロジェクト: realstartca/meng-test
        static void SellTriggerThresholdReachedHandler(object sender, ThresholdReachedEventArgs e)
        {
            Console.WriteLine($"The sell trigger threshold of {e.Threshold} was reached at {e.TimeReached}, current price is {e.Price}.");

            // User plugin sell logic here
        }
コード例 #20
0
 public void OnScoreReached(ThresholdReachedEventArgs e)
 {
     System.Console.WriteLine("applicant subscriber");
 }