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);
                }
            });
        }
Exemplo n.º 2
0
 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());
     }
 }
Exemplo n.º 3
0
        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);
                }
            });
        }
Exemplo n.º 4
0
 string GetFormattedTimestamp()
 {
     return(_timeStamper?.GetFormattedTimestamp());
 }