/// <summary> /// Creates a new SettableStopwatch with a custom inital time /// </summary> /// <param name="ticks">The initial time in ticks</param> public SettableStopwatch(long ticks = 0) { time = new TimeSpan(ticks); timer.AutoReset = false; timer.Stop(); timer.Elapsed += (sender, e) => { ThresholdReached?.Invoke(this, EventArgs.Empty); }; }
public override void OnScrolled(RecyclerView recyclerView, int dx, int dy) { // dY > 0 means scroll down if (dy > 0) { TotalItemCount = LayoutManager.ItemCount; LastVisibleItemPosition = LayoutManager.FindLastCompletelyVisibleItemPosition(); // as the number of items passed equals to LastVisibleItemPosition + 1 PassedItemCount = LastVisibleItemPosition + 1; // Check the presence of loading item int indexSubstitution = RecyclerViewAdapter.IsLoadingMore ? 1 : 0; // reach threshold if (PassedItemCount + TriggerThreshold == (TotalItemCount - indexSubstitution)) { if (!triggerLock) { ThresholdReached?.Invoke(this, EventArgs.Empty); triggerLock = true; } } else { triggerLock = false; } } bool isOnTop = LayoutManager.FindFirstCompletelyVisibleItemPosition() == 0 || TotalItemCount == 0; Scroll?.Invoke(this, new ScrollEventArgs(isOnTop)); }
public void Add(int x) { total += x; if (total >= threshold) { ThresholdReached?.Invoke(this, EventArgs.Empty); } }
public CurrentTimeArgs(int hours, int minutes, int seconds, int currentRound, ThresholdReached threshold = ThresholdReached.NotSet) { this.Hours = hours; this.Minutes = minutes; this.Seconds = seconds; this.CurrentRound = currentRound; this.Threshold = threshold; }
public void Increment() { _count++; if (_count >= _threshold) { ThresholdReached?.Invoke(this, EventArgs.Empty); } }
private void OnLevelReached(LevelThreshold levelThreshold) { levelThreshold.LevelReached -= OnLevelReached; ThresholdReached?.Invoke(levelThreshold); _currentLevel++; _distanceBetweenThreshold += _heightIncreasement; _currentThresholdPositionY += _distanceBetweenThreshold; SpawnThreshold(_currentThresholdPositionY, _currentLevel); }
public decimal ConvertToDollars(decimal euroAmount) { decimal result; if (euroAmount > 10000) { ThresholdReached.Invoke(); } result = euroAmount * (decimal)1.10; return(result); }
public decimal ConvertToEuro(decimal dollarsAmount) { decimal result; if (dollarsAmount > 10000) { ThresholdReached.Invoke(); } result = dollarsAmount * (decimal)0.91; return(result); }
public void UpdateCounter() { if (Counter >= threshold) { if (ThresholdReached != null) { ThresholdReached.Invoke(this, EventArgs.Empty); } } Counter++; }
public void IncreaseCount() { this.count += 1; if (this.count >= this.threshold) { ThresholdReached?.Invoke(this, new ThresholdReachedEventArgs() { Message = $"{this.count} is past the {this.threshold} threshold" }); //EventPublisherThresholdReached(new Counter_ThresholdReachedEventArgs() { Message = $"{this.count} is past the {this.threshold} threshold" }); } }
public void Add(int value) { total += value; if (total >= THRESHOLD) { // var args = new ThresholdReachedEventArgs(); args.Threshold = THRESHOLD; args.TimeReached = DateTime.Now; ThresholdReached?.Invoke(this, args); } }
protected virtual void OnThresholdReached(ThresholdReachedEventArgs e) { /* * // C# 5.0 * EventHandler<ThresholdReachedEventArgs> handler = ThresholdReached; * if (handler != null) * { * handler(this, e); * } */ // C# 6.0 ThresholdReached?.Invoke(this, e); }
protected virtual void OnThresholdReached(ThresholdReachedEventArgs e) { ThresholdReached?.Invoke(this, e); //等价于 // //创建一个委托变量handler,受EventHandler<ThresholdReachedEventArgs>约束 // //handler获得事件ThresholdReached,handler可以在事件发生时调用事件订阅者方法 // EventHandler<ThresholdReachedEventArgs> handler = ThresholdReached; ////事件订阅者如果不为空 // if (handler != null) // { // //间接调用事件订阅者的事件处理器方法。 // handler(this, args); // } }
protected virtual void OnThresholdReached(EventArgs e) { //This line actually fires the event and any listening methods will be invoked ThresholdReached?.Invoke(this, e); /*The below are older ways of doing the above */ //EventHandler handler = ThresholdReached; //handler?.Invoke(this, e); //EventHandler handler = ThresholdReached; //if (handler != null) //{ // handler(this, e); //} }
private void OnThresholdReached(int threshold) { ThresholdReached?.Invoke(threshold); }
private void OnThresholdReached(ThresholdReachedEventArgs args) { ThresholdReached?.Invoke(this, args); }
protected virtual void OnThresholdReached(string message) { ThresholdReached?.Invoke(this, new SendEventArg(message)); }
private void OnThresholdreached(ThresholdEventArgs threshold) { ThresholdReached?.Invoke(this, threshold); }
protected virtual void OnThresholdReached(ThresholdReachedEventArgs e) { ThresholdReached?.Invoke(this, e); }
public void Handle(ThresholdReached data) { context.Queue.Add(new DataGetTaskSchedule(data.Peer)); }
/// <summary> /// Publish the ThresholdReached event when the threshold has been reached /// </summary> /// <param name="args"></param> private void PublishThresholdReachedEvent(ThresholdReachedEventArgs args) { ThresholdReached?.Invoke(this, args); }
public virtual void OnThresholdReached(EventArgs e) { ThresholdReached?.Invoke(this, e); }
private void OnThresholdReached(ChatEventHandler handler) { ThresholdReached?.Invoke(this, handler); }