//private void updateNodeStateImage( // FileGroup fileGroup, // FileGroupStates state ) //{ // if ( treeView.Nodes.Count > 0 ) // { // // For now, FileGroups are always in level 1. // // This changes later. // foreach ( TreeListNode node in treeView.Nodes[0].Nodes ) // { // var fg = (FileGroup)node.Tag; // if ( fg.GetChecksum( _project ) == fileGroup.GetChecksum( _project ) ) // { // updateNodeStateImage( node, state ); // break; // } // } // } //} private void updateNodeStateImage( TreeListNode node, AsynchronousMode asynchronous) { if (node != null) { var si = node.Tag as ITranslationStateInformation; if (si != null) { if (asynchronous == AsynchronousMode.Synchronous) { var stateImageIndex = (int)si.TranslationStateColor; if (node.StateImageIndex != stateImageIndex) { node.StateImageIndex = stateImageIndex; if (si is FileGroup) { foreach (TreeListNode childNode in node.Nodes) { childNode.StateImageIndex = stateImageIndex; } } } } else { // Fill with default. if (node.StateImageIndex != (int)FileGroupStateColor.Grey) { node.StateImageIndex = (int)FileGroupStateColor.Grey; if (si is FileGroup) { foreach (TreeListNode childNode in node.Nodes) { childNode.StateImageIndex = (int)FileGroupStateColor.Grey; } } } // -- // Actually calculate, populate when finished calculating. var info = new AsyncInfo { Node = node, StateInfo = si }; enqueue(info); } } // -- // Update parents. updateNodeStateImage(node.ParentNode, asynchronous); } }
private void enqueue(AsyncInfo info) { lock (_queue) { _queue.Enqueue(info); } if (!updateNodeStateImageBackgroundworker.IsBusy) { updateNodeStateImageBackgroundworker.RunWorkerAsync(); } }
public IAsyncOperation <TranscriptionResult> ListTranscriptionsAsync(string recordingSid, int?pageNumber, int?count) { return((IAsyncOperation <TranscriptionResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListTranscriptionsAsyncInternal(recordingSid, pageNumber, count))); }
/// <summary> /// Retrieve the details of a single transcription. /// Makes a GET request to a Transcription Instance resource. /// </summary> /// <param name="transcriptionSid">The Sid of the transcription to retrieve</param> public IAsyncOperation <Transcription> GetTranscriptionAsync(string transcriptionSid) { return((IAsyncOperation <Transcription>)AsyncInfo.Run((System.Threading.CancellationToken ct) => GetTranscriptionAsyncInternal(transcriptionSid))); }
/// <summary> /// Returns a set of Transcriptions that includes paging information, sorted by 'DateUpdated', with most recent transcripts first. /// Makes a GET request to the Transcriptions List resource. /// </summary> public IAsyncOperation <TranscriptionResult> ListTranscriptionsAsync() { return((IAsyncOperation <TranscriptionResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListTranscriptionsAsyncInternal(null, null))); }
public IAsyncAction PreloadAdAsync(IAdSource adSource) { return(AsyncInfo.Run(c => PreloadAdAsync(adSource, c))); }
public IAsyncActionWithProgress <AdStatus> PlayAdAsync(IAdSource adSource, TimeSpan?startTimeout) { return(AsyncInfo.Run <AdStatus>((c, p) => PlayAdAsync(adSource, startTimeout, c, p))); }
public IAsyncOperation <bool> CancelAd(bool force) { return(AsyncInfo.Run(c => CancelActiveAd(force))); }
public IAsyncOperationWithProgress <DownloadableItem, double> DownloadFileAsync(string originalFileName, int dcId, TLInputDocumentFileLocation fileLocation, int fileSize) { return(AsyncInfo.Run <DownloadableItem, double>((token, progress) => { var tsc = new TaskCompletionSource <DownloadableItem>(); var downloadableItem = GetDownloadableItem(originalFileName, dcId, fileLocation, null, fileSize); downloadableItem.Callback = tsc; downloadableItem.Progress = progress; var downloadedCount = downloadableItem.Parts.Count(x => x.Status == PartStatus.Processed); var count = downloadableItem.Parts.Count; var isComplete = downloadedCount == count; if (isComplete) { //var id = downloadableItem.InputDocumentLocation.Id; //var accessHash = downloadableItem.InputDocumentLocation.AccessHash; var fileExtension = Path.GetExtension(downloadableItem.FileName.ToString()); var fileName = GetFileName(downloadableItem.InputDocumentLocation, fileExtension); //string.Format("document{0}_{1}{2}", id, accessHash, fileExtension); Func <DownloadablePart, string> getPartName = x => downloadableItem.InputDocumentLocation.GetPartFileName(x.Number); //string.Format("document{0}_{1}_{2}.dat", id, accessHash, x.Number); FileUtils.MergePartsToFile(getPartName, downloadableItem.Parts, fileName); downloadableItem.IsoFileName = fileName; downloadableItem.Progress.Report(1.0); downloadableItem.Callback.TrySetResult(downloadableItem); } else { downloadableItem.Progress.Report(downloadedCount / (double)count); lock (_itemsSyncRoot) { bool addFile = true; foreach (var item in _items) { if (item.InputDocumentLocation.AccessHash == fileLocation.AccessHash && item.InputDocumentLocation.Id == fileLocation.Id) { downloadableItem.Callback = item.Callback; downloadableItem.Progress = item.Progress; addFile = false; Debug.WriteLine("Already downloading document"); //item.SuppressMerge = true; //item. //if (item.Owner == owner) //{ // Execute.ShowDebugMessage("Cancel document=" + fileLocation.Id); // addFile = false; // break; //} } } if (addFile) { _items.Add(downloadableItem); } } StartAwaitingWorkers(); } return tsc.Task; })); }