/// <summary> /// Function working as a new thread used to launch dhe FindBestPath method asynchronously. /// </summary> /// <param name="param"><see cref="FindPathAsynchParams{T}"/> casted to <see cref="object"/>.</param> private void DoFindBestPathAsynch(object param) { FindPathAsynchParams <T> findParams = (FindPathAsynchParams <T>)param; Path <T> path = this.FindBestPath(); findParams.PathsFoundEventDelegate?.Invoke(new Path <T>[] { path }, findParams.OperationID); this._threadDictionary.Remove(findParams.OperationID); }
/// <summary> /// Function working as a new thread used to launch dhe FindAllPaths method asynchronously. /// </summary> /// <param name="param"><see cref="FindPathAsynchParams{T}"/> casted to <see cref="object"/>.</param> private void DoFindAllPathsAsynch(object param) { FindPathAsynchParams <T> findParams = (FindPathAsynchParams <T>)param; Path <T>[] paths = this.FindAllPaths(); findParams.PathsFoundEventDelegate?.Invoke(paths, findParams.OperationID); this._threadDictionary.Remove(findParams.OperationID); }
/// <summary> /// Find all the paths avalaible between map start point and destination point asynchronously. /// </summary> /// <returns>Async operation <see cref="Guid"/>.</returns> public Guid FindAllPathsAsynch() { Guid operationID = Guid.Empty; Thread findThread = new Thread(new ParameterizedThreadStart(this.DoFindAllPathsAsynch)); FindPathAsynchParams <T> findParams = new FindPathAsynchParams <T>(); operationID = Guid.NewGuid(); this._threadDictionary.Add(operationID, findThread); findParams.OperationID = operationID; findParams.PathsFoundEventDelegate = this.PathsFound; findThread.Start(findParams); return(operationID); }