public void Add(int x) { total += x; if (total >= threshold) { ThresholdReachedEventArgs args = new ThresholdReachedEventArgs(); args.Threshold = threshold; args.TimeReached = DateTime.Now; OnThresholdReached(args); } }
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"); } }
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); } }
public void Add(int x) { total += x; if (total >= threshold) { ThresholdReachedEventArgs eventArgs = new ThresholdReachedEventArgs() { Threshold = threshold, Value = total, TimeReached = DateTime.UtcNow }; OnThresholdReached(eventArgs); } }
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); } }
public void DriverStart() { new Thread(() => { total += 1; if (total >= threshold) { ThresholdReachedEventArgs args = new ThresholdReachedEventArgs(); args.Threshold = threshold; OnThresholdeReached(args); } Thread.Sleep(20); }).Start(); }
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); } }
private static void Raiser_ThresholdReached(object sender, ThresholdReachedEventArgs e) { Const.OpcDatasource.CoalOnBelt = false; }
// 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); }
/// <summary> /// 超时未接收数据后引发的事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Raiser_ThresholdReached(object sender, ThresholdReachedEventArgs e) { this.GnssInfo.Working = false; }
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; }
private void Raiser_ThresholdReached(object sender, ThresholdReachedEventArgs e) { //接收超时的处理方法 }
protected virtual void OnThresholdeReached(ThresholdReachedEventArgs e) { EventHandler<ThresholdReachedEventArgs> handler = ThresholdReached; if (handler != null) { handler(this, e); } }
static void c_ThresholdReached(object sender, ThresholdReachedEventArgs e) { Console.WriteLine("The threshold of {0} was reached at {1}.", e.Threshold, e.TimeReached); }
protected virtual void OnThresholdReached(ThresholdReachedEventArgs e) { this.ThresholdReached?.Invoke(this, e); }
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; }
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); }
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 }
public void OnScoreReached(ThresholdReachedEventArgs e) { System.Console.WriteLine("applicant subscriber"); }