public void Run() { if (Plan.PositionLogs == null || Plan.PositionLogs.Count == 0) { _log.LogError(Plan.Id, "There are no positions to execute the forecast"); throw new ForecastServiceException("There are no positions to execute the forecast"); } if (Plan.GetStatus() == ForecastPlanStatus.Running) { _log.LogWarning(Plan.Id, "Already Running"); throw new ForecastServiceException("Already Running"); } _dataService.DeleteResults(Plan.Id); Plan.SetStatus(ForecastPlanStatus.Running); _dataService.UpdateForecastPlan(Plan); //_dataService.DeleteResults(Plan.Id); var runDelegate = new RunDelegate(ExecutePositions); runDelegate.BeginInvoke(RunCallback, runDelegate); }