mirror of
https://github.com/chsakell/aspnet-core-signalr-angular.git
synced 2025-12-22 17:27:48 +00:00
remove timer service
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace LiveGameFeed.Core.MvcTimer
|
||||
{
|
||||
public interface ITimerService
|
||||
{
|
||||
event EventHandler TimerElapsed;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace LiveGameFeed.Core.MvcTimer
|
||||
{
|
||||
public class TimerEventArgs : EventArgs
|
||||
{
|
||||
public TimerEventArgs(int value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public int Value { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace LiveGameFeed.Core.MvcTimer
|
||||
{
|
||||
public class TimerService : ITimerService
|
||||
{
|
||||
private Timer _timer;
|
||||
readonly Random _random = new Random();
|
||||
public event EventHandler TimerElapsed;
|
||||
|
||||
public TimerService(IOptions<TimerServiceConfiguration> options)
|
||||
{
|
||||
var optionsTimerServiceConfiguration = options;
|
||||
_timer = new Timer(
|
||||
OnTimerElapsed,
|
||||
null,
|
||||
optionsTimerServiceConfiguration.Value.DueTime,
|
||||
optionsTimerServiceConfiguration.Value.Period);
|
||||
}
|
||||
|
||||
private void OnTimerElapsed(object sender)
|
||||
{
|
||||
TimerElapsed?.Invoke(this, new TimerEventArgs(_random.Next(0, 100)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace LiveGameFeed.Core.MvcTimer
|
||||
{
|
||||
public class TimerServiceConfiguration
|
||||
{
|
||||
public int DueTime { get; set; }
|
||||
|
||||
public int Period { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user