public override void OnCreate() { DispatchNotificationThatServiceIsRunning(); Log.Info(TAG, "OnCreate: the service is initializing."); base.OnCreate(); timestamper = new UtcTimestamper(); handler = new Handler(); // This Action is only for demonstration purposes. runnable = new Action(() => { if (timestamper != null) { UpdateNotification(timestamper.GetFormattedTimestamp()); Log.Debug(TAG, timestamper.GetFormattedTimestamp()); handler.PostDelayed(runnable, DELAY_BETWEEN_LOG_MESSAGES); } }); }
private string LongWorkerAsync() { Debug.WriteLine(System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() + " LongWorkerAsync"); Task.Delay(7001).Wait(); if (cancelTokenSource.Token.IsCancellationRequested) { return("work time over~!"); } else { return(timestamper.GetFormattedTimestamp()); } }
public override void OnCreate() { base.OnCreate(); Log.Info(_tag, "OnCreate: the service is initializing."); _timeStamper = new UtcTimestamper(); _handler = new Handler(); // This Action is only for demonstration purposes. _runnable = new Action(() => { if (_timeStamper != null) { Log.Debug(_tag, _timeStamper.GetFormattedTimestamp()); _handler.PostDelayed(_runnable, DelayBetweenLogMessages); } }); }
string GetFormattedTimestamp() { return(_timeStamper?.GetFormattedTimestamp()); }