in Source/NuGetGallery.Worker/Jobs/WorkerJob.cs [32:81]
public void ExecuteTask(OpsTask task)
{
Logger.Info("Starting Execution of {0}", task.GetType().Name);
task.Log = Logger;
bool completed = false;
IAsyncCompletionTask completion = task as IAsyncCompletionTask;
try
{
task.Execute();
}
catch (Exception ex)
{
Logger.Error("Execution of {0} failed: {1}", task.GetType().Name, ex.ToString());
return;
}
if (completion != null && !completion.DoNotPoll)
{
DateTime startUtc = DateTime.UtcNow;
while (DateTime.UtcNow - startUtc < completion.MaximumPollingLength && !completed)
{
try
{
completed = completion.PollForCompletion();
}
catch (Exception ex)
{
Logger.Error("Polling for completion of {0} failed: {1}", task.GetType().Name, ex.ToString());
return;
}
}
}
else
{
completed = true;
}
if (!completed)
{
// If we're here, it means we hit the max poll length without recieving a success response
Logger.Error("Asynchronous Execution of {0} failed!");
}
else
{
Logger.Info("Completed Execution of {0}", task.GetType().Name);
}
}