internal override void Execute()
            {
                TaskMetadata   taskToBeCancelledMetadata;
                ExecutionToken taskToBeCancelledToken;

                lock (scheduler.resourcesLock)
                {
                    if (scheduler.taskToToken.ContainsKey(completedTask))
                    {
                        taskToBeCancelledMetadata = scheduler.taskToMetadata[completedTask];
                        taskToBeCancelledToken    = scheduler.taskToToken[completedTask];
                        //If task is holding some resources, queue the unlock resources event and then cancel task if exists event again
                        //This will unlock the first resource before trying to delete the task again
                        if (scheduler.taskHoldingResources[completedTask].Count() > 0)
                        {
                            scheduler.eventQueue.Add(new TaskWantsToUnlockResourceEvent(scheduler, taskToBeCancelledToken, taskToBeCancelledToken.waitingOnResponse, scheduler.taskHoldingResources[completedTask][0]));
                            scheduler.eventQueue.Add(new CancelTaskIfExistsEvent(scheduler, completedTask));
                            return;
                        }

                        scheduler.EraseTaskFromMemory(completedTask);
                        scheduler.eventQueue.Add(new ScheduleTasksEvent(scheduler));
                    }
                }
            }