1
0
mirror of https://github.com/Kopano-dev/kopano-ol-extension.git synced 2023-10-10 13:37:40 +02:00

[KOE-176] Additional logging for task execution

This commit is contained in:
Patrick Simpson 2018-09-25 12:28:26 +03:00
parent 87a3a67b12
commit 41c547bf16
2 changed files with 26 additions and 3 deletions

View File

@ -71,6 +71,11 @@ namespace Acacia.Utils
}
}
public override string ToString()
{
return Id;
}
}
public abstract class TaskExecutor
@ -136,8 +141,13 @@ namespace Acacia.Utils
public static void Task(AcaciaTask task, bool synchronous = false)
{
Logger.Instance.Debug(typeof(Tasks), "TASK added: {0}", task);
if (synchronous)
{
Logger.Instance.Debug(typeof(Tasks), "TASK exec synchronous 1: {0}", task);
task.Execute();
Logger.Instance.Debug(typeof(Tasks), "TASK exec synchronous 2: {0}", task);
}
else
Executor.AddTask(task);
}

View File

@ -38,16 +38,29 @@ namespace Acacia.Utils
private void Worker()
{
while (!_tasks.IsCompleted)
try
{
AcaciaTask task = _tasks.Take();
PerformTask(task);
while (!_tasks.IsCompleted)
{
Logger.Instance.Debug(this, "Take task 1");
AcaciaTask task = _tasks.Take();
Logger.Instance.Debug(this, "Take task 2: {0}", task);
PerformTask(task);
Logger.Instance.Debug(this, "Take task 3: {0}", task);
}
Logger.Instance.Debug(this, "Worker completed");
}
catch(Exception e)
{
Logger.Instance.Debug(this, "Worker failure: {0}", e);
}
}
protected override void EnqueueTask(AcaciaTask task)
{
Logger.Instance.Debug(this, "EnqueueTask 1: {0}", task);
_tasks.Add(task);
Logger.Instance.Debug(this, "EnqueueTask 2: {0}", task);
}
override public string Name { get { return "Background"; } }