/// <summary> /// This function save someuser (Need to implement). /// </summary> /// <param name="state"></param> private void Save(object state) { m_vDatabase.Save(ResourcesManager.GetInMemoryLevels()); m_vDatabase.Save(m_vAlliances.Values.ToList()); if (m_vTimerCanceled) { TimerReference.Dispose(); } }
public void TestSingleCommandRemoveListener() { HystrixTimer timer = HystrixTimer.GetInstance(); TestListener l1 = new TestListener(50, "A"); timer.AddTimerListener(l1); TestListener l2 = new TestListener(50, "B"); TimerReference l2ref = timer.AddTimerListener(l2); try { Time.Wait(500); } catch (Exception e) { output.WriteLine(e.ToString()); } // we should have 7 or more 50ms ticks within 500ms output.WriteLine("l1 ticks: " + l1.TickCount.Value); output.WriteLine("l2 ticks: " + l2.TickCount.Value); Assert.True(l1.TickCount.Value > 7); Assert.True(l2.TickCount.Value > 7); // remove l2 l2ref.Dispose(); // reset counts l1.TickCount.Value = 0; l2.TickCount.Value = 0; // wait for time to pass again try { Time.Wait(500); } catch (Exception e) { output.WriteLine(e.ToString()); } // we should have 7 or more 50ms ticks within 500ms output.WriteLine("l1 ticks: " + l1.TickCount.Value); output.WriteLine("l2 ticks: " + l2.TickCount.Value); // l1 should continue ticking Assert.True(l1.TickCount.Value > 7); // we should have no ticks on l2 because we removed it output.WriteLine("tickCount.Value: " + l2.TickCount.Value + " on l2: " + l2); Assert.Equal(0, l2.TickCount.Value); }