public VideoReference ConsumeAndFinishUpload() { var timeoutStopwatch = new Stopwatch(); timeoutStopwatch.Start(); while (timeoutStopwatch.ElapsedMilliseconds < int.Parse(config.AppSettings["VideoUploadTimeoutMilliseconds"])) { if (!isUploading) { var audio = AudioTrack.FromVideo(Path.Combine(UploadDirectory(), fileName)); return(dispatcher.Dispatch(VideoActions.CreateVideoReference(new VideoReference { FilePath = Path.Combine(UploadDirectory(), fileName), AudioFilePath = audio.AudioFilePath }))); } } isUploading = false; throw new Exception("Video upload timed out"); }