Modernization Fixes & Updates to Default Values (#3)
This commit is contained in:
parent
445eddff68
commit
dcf64091b1
768 changed files with 10507 additions and 14196 deletions
|
|
@ -40,9 +40,7 @@ namespace Server
|
|||
|
||||
public delegate void TimerCallback();
|
||||
|
||||
public delegate void TimerStateCallback(object state);
|
||||
|
||||
public delegate void TimerStateCallback<T>(T state);
|
||||
public delegate void TimerStateCallback<in T>(T state);
|
||||
|
||||
public class Timer
|
||||
{
|
||||
|
|
@ -293,8 +291,7 @@ namespace Server
|
|||
|
||||
string key = t.ToString();
|
||||
|
||||
List<Timer> list;
|
||||
hash.TryGetValue(key, out list);
|
||||
hash.TryGetValue(key, out List<Timer> list);
|
||||
|
||||
if (list == null)
|
||||
hash[key] = list = new List<Timer>();
|
||||
|
|
@ -517,36 +514,6 @@ namespace Server
|
|||
return t;
|
||||
}
|
||||
|
||||
public static Timer DelayCall(TimerStateCallback callback, object state)
|
||||
{
|
||||
return DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback, state);
|
||||
}
|
||||
|
||||
public static Timer DelayCall(TimeSpan delay, TimerStateCallback callback, object state)
|
||||
{
|
||||
return DelayCall(delay, TimeSpan.Zero, 1, callback, state);
|
||||
}
|
||||
|
||||
public static Timer DelayCall(TimeSpan delay, TimeSpan interval, TimerStateCallback callback, object state)
|
||||
{
|
||||
return DelayCall(delay, interval, 0, callback, state);
|
||||
}
|
||||
|
||||
public static Timer DelayCall(TimeSpan delay, TimeSpan interval, int count, TimerStateCallback callback,
|
||||
object state)
|
||||
{
|
||||
Timer t = new DelayStateCallTimer(delay, interval, count, callback, state);
|
||||
|
||||
if (count == 1)
|
||||
t.Priority = ComputePriority(delay);
|
||||
else
|
||||
t.Priority = ComputePriority(interval);
|
||||
|
||||
t.Start();
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DelayCall<T>(..)
|
||||
|
|
@ -571,10 +538,7 @@ namespace Server
|
|||
{
|
||||
Timer t = new DelayStateCallTimer<T>(delay, interval, count, callback, state);
|
||||
|
||||
if (count == 1)
|
||||
t.Priority = ComputePriority(delay);
|
||||
else
|
||||
t.Priority = ComputePriority(interval);
|
||||
t.Priority = ComputePriority(count == 1 ? delay : interval);
|
||||
|
||||
t.Start();
|
||||
|
||||
|
|
@ -609,34 +573,6 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
private class DelayStateCallTimer : Timer
|
||||
{
|
||||
private object m_State;
|
||||
|
||||
public DelayStateCallTimer(TimeSpan delay, TimeSpan interval, int count, TimerStateCallback callback,
|
||||
object state) : base(delay, interval, count)
|
||||
{
|
||||
Callback = callback;
|
||||
m_State = state;
|
||||
|
||||
RegCreation();
|
||||
}
|
||||
|
||||
public TimerStateCallback Callback{ get; }
|
||||
|
||||
public override bool DefRegCreation => false;
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
Callback?.Invoke(m_State);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"DelayStateCall[{FormatDelegate(Callback)}]";
|
||||
}
|
||||
}
|
||||
|
||||
private class DelayStateCallTimer<T> : Timer
|
||||
{
|
||||
private T m_State;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue