/// <summary> /// Merges the image in a folder to create a single image. Algorithm will run until /// the photographs in the folder are merged. /// </summary> /// <param name="pathToUse"></param> /// <returns></returns> public Image MergeImagesNoTimeout(string pathToUse) { MergeImages mergeImages = new MergeImages(pathToUse); Image panoramaPicture; return(panoramaPicture = mergeImages.CreatePanoramaFromFolder()); }
/// <summary> /// Merges the image in a folder to create a single image. Timeouts after a specific amount of /// time has passed, defined by the user. /// </summary> /// <param name="pathToUse"></param> /// <param name="maxRunTimeSeconds"></param> /// <returns>Panorama Image</returns> public Image MergeImagesWithTimeout(string pathToUse, uint maxRunTimeSeconds) { //Runs asynchronously. var task = Task.Run(() => { MergeImages mergeImages = new MergeImages(pathToUse); Image panoramaPicture; return(panoramaPicture = mergeImages.CreatePanoramaFromFolder()); }); //Waits for the task to be finished in maxRunTimeSeconds. bool isCompletedSuccessfully = task.Wait(TimeSpan.FromSeconds(maxRunTimeSeconds)); if (isCompletedSuccessfully) { return(task.Result); } else { return(null); } }