Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Fire()

bool System.Net.TimerThread.TimerNode.Fire ( )
inlinepackage

Definition at line 244 of file TimerThread.cs.

245 {
246 if (_timerState == TimerState.Sentinel && System.Net.NetEventSource.Log.IsEnabled())
247 {
248 System.Net.NetEventSource.Info(this, "TimerQueue tried to Fire a Sentinel.", "Fire");
249 }
250 if (_timerState != 0)
251 {
252 return true;
253 }
254 int tickCount = Environment.TickCount;
255 if (IsTickBetween(base.StartTime, base.Expiration, tickCount))
256 {
257 if (System.Net.NetEventSource.Log.IsEnabled())
258 {
259 System.Net.NetEventSource.Info(this, $"TimerThreadTimer#{base.StartTime}::Fire() Not firing ({base.StartTime} <= {tickCount} < {base.Expiration})", "Fire");
260 }
261 return false;
262 }
263 bool flag = false;
265 {
266 if (_timerState == TimerState.Ready)
267 {
268 if (System.Net.NetEventSource.Log.IsEnabled())
269 {
270 System.Net.NetEventSource.Info(this, $"TimerThreadTimer#{base.StartTime}::Fire() Firing ({base.StartTime} <= {tickCount} >= " + base.Expiration + ")", "Fire");
271 }
272 _timerState = TimerState.Fired;
273 Next.Prev = Prev;
274 Prev.Next = Next;
275 Next = null;
276 Prev = null;
277 flag = _callback != null;
278 }
279 }
280 if (flag)
281 {
282 try
283 {
284 Callback callback = _callback;
285 object context = _context;
286 _callback = null;
287 _context = null;
288 callback(this, tickCount, context);
289 }
290 catch (Exception ex)
291 {
293 {
294 throw;
295 }
296 if (System.Net.NetEventSource.Log.IsEnabled())
297 {
298 System.Net.NetEventSource.Error(this, $"exception in callback: {ex}", "Fire");
299 }
300 }
301 }
302 return true;
303 }
static bool IsFatal(Exception exception)
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
static void Error(object thisOrContextObject, FormattableString formattableString, [CallerMemberName] string memberName=null)
static bool IsTickBetween(int start, int end, int comparand)

References System.Net.TimerThread.TimerNode._callback, System.Net.TimerThread.TimerNode._context, System.Net.TimerThread.TimerNode._queueLock, System.Net.TimerThread.TimerNode._timerState, System.Net.NetEventSource.Error(), System.Net.NetEventSource.Info(), System.Net.ExceptionCheck.IsFatal(), System.Net.TimerThread.IsTickBetween(), System.Net.NetEventSource.Log, System.Net.TimerThread.TimerNode.Next, System.Net.TimerThread.TimerNode.Prev, and System.Environment.TickCount.

Referenced by System.Net.TimerThread.TimerQueue.Fire().