private void Sender(object state) { Tick -= 1000; var context = GlobalHost.ConnectionManager.GetHubContext<Lotereya.Hubs.Timing>(); /*int hours = Tick / 3600000; int minutes = (Tick - hours * 3600000) / 60000; int second = (Tick - hours * 3600000 - minutes * 60000) / 1000;*/ //context.Clients.All.addMessage(Helper.GetMessage(((DataStructure)state).Type), Helper.Converter(hours) + ":" + Helper.Converter(minutes) + ":" + Helper.Converter(second)); context.Clients.All.secondIs(((DataStructure)state).Type,Tick / 1000); if (Tick <= 0) { if (timer != null) { timer.Dispose(); timer = null; } if (((DataStructure)state).Type == 2) timerStartEvent.FireDisposeEvent(); } }
public void Stop() { isStoped = true; if (timerStartBeforeEvent != null) { timerStartBeforeEvent.Dispose(); timerStartBeforeEvent = null; } if (timerStartEvent != null) { timerStartEvent.Dispose(); timerStartEvent = null; } if (timerStartAfterEvent != null) { timerStartAfterEvent.Dispose(); timerStartAfterEvent = null; } if (timer != null) { timer.Dispose(); timer = null; } var context = GlobalHost.ConnectionManager.GetHubContext<Lotereya.Hubs.Timing>(); context.Clients.All.endDraw(); }
private void Loter(object state) { var data = (DataStructure)state; if (data.Type == 1) { timerStartBeforeEvent.FireStartEvent(); } Tick = data.Period; if (timer != null) { timer.Dispose(); timer = null; if (data.Type == 3) timerStartEvent.FireDisposeEvent(); } timer = new CustomTimer(Sender, state, 0, 1000, null,null); //var context = GlobalHost.ConnectionManager.GetHubContext<Lotereya.Hubs.Timing>(); //context.Clients.All.addMessage("Начался розыграш"); }
public void Start() { if (isStoped) { var context = GlobalHost.ConnectionManager.GetHubContext<Lotereya.Hubs.Timing>(); context.Clients.All.startDraw(); Lotereya.Hubs.Timing.SendCount(); isStoped = false; timerStartBeforeEvent = new CustomTimer(Loter, new DataStructure() { Type = 1, Period = PeriodBeforeEvent }, 1, PeriodAfterEvent + PeriodEvent + PeriodBeforeEvent, null, timerStartBeforeEvent_onStart); timerStartEvent = new CustomTimer(Loter, new DataStructure() { Type = 2, Period = PeriodEvent }, PeriodBeforeEvent, PeriodAfterEvent + PeriodEvent + PeriodBeforeEvent, timerStartEvent_onDispose,null); timerStartAfterEvent = new CustomTimer(Loter, new DataStructure() { Type = 3, Period = PeriodAfterEvent }, PeriodEvent + PeriodBeforeEvent + 1, PeriodAfterEvent + PeriodEvent + PeriodBeforeEvent, null,null); } }