Exemple #1
0
        // Stop this service.
        protected override void OnStop()
        {
            Log("OnStop", "Stopping...");

            this.RequestAdditionalTime(4000);

            StopWcf();

            // gracefully shut down all schedules:
            foreach (TaskBase t in _tasks.Tasks)
            {
                t.Schedule.Exit();
            }

            // save task list to _c1rsconfPath:
            if (!string.IsNullOrEmpty(_c1rsconfPath))
            {
                try
                {
                    Log("OnStop", string.Format("Saving task list to {0}...", _c1rsconfPath));
                    _tasks.Save(_c1rsconfPath);
                    Log("OnStop", string.Format("Task list saved to {0}.", _c1rsconfPath));
                }
                catch (Exception ex)
                {
                    Log("OnStop", string.Format("Could not save task list to {0}, error: {1}", _c1rsconfPath, ex.Message));
                }
            }

            Log("OnStop", "Stopped.");

            // Indicate a successful exit.
            this.ExitCode = 0;
        }
Exemple #2
0
 public string SerializeTaskListHolder()
 {
     using (MemoryStream ms = new MemoryStream())
     {
         _tasks.Save(ms);
         ms.Seek(0, SeekOrigin.Begin);
         return(UTF8Encoding.Default.GetString(ms.GetBuffer()));
     }
 }