void bw_Completed(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { _currentOperation.SetStatus(LoadOperationStatus.Failed); } else if (e.Cancelled) { _currentOperation.SetStatus(LoadOperationStatus.Cancelled); _pendingOperations.Clear(); } if (_currentOperation.OnOperationCompleted != null) { _currentOperation.OnOperationCompleted(_currentOperation); } if (_pendingOperations.Count > 0) { _currentOperation = _pendingOperations.Dequeue(); _currentOperation.OperationWillStart(); _bw.RunWorkerAsync(_currentOperation); } else { _bw = null; _currentOperation = null; } }
void bw_Work(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; if (worker.CancellationPending) { e.Cancel = true; return; } LoadingOperation op = e.Argument as LoadingOperation; GATData[] loadedData; while (true) { loadedData = op.LoadNext(worker, _buffer); if (loadedData != null) { worker.ReportProgress(0, new ProgressInfo(loadedData, op.CurrentFileName)); } else { break; } } if (op.Status == LoadOperationStatus.Cancelled) { e.Cancel = true; } }
// currently the normalizeTypeNmFn is only needed during saves, not during queries. public JsonEntityConverter(EntityManager entityManager, MergeStrategy mergeStrategy, LoadingOperation loadingOperation, Func<String, String> normalizeTypeNameFn = null) { _entityManager = entityManager; _metadataStore = entityManager.MetadataStore; _mergeStrategy = mergeStrategy; _loadingOperation = loadingOperation; _normalizeTypeNameFn = normalizeTypeNameFn; _allEntities = new List<IEntity>(); }
// currently the normalizeTypeNmFn is only needed during saves, not during queries. public JsonEntityConverter(EntityManager entityManager, MergeStrategy mergeStrategy, LoadingOperation loadingOperation, Func <String, String> normalizeTypeNameFn = null) { _entityManager = entityManager; _metadataStore = entityManager.MetadataStore; _mergeStrategy = mergeStrategy; _loadingOperation = loadingOperation; _normalizeTypeNameFn = normalizeTypeNameFn; _allEntities = new List <IEntity>(); }
/// <summary> /// Convenience method for loading files asynchronously /// to a sample bank. This method instantiates, configures and /// enqueues a AGATLoadingOperation. Use NewOperation if you need /// more control over progress callbacks. /// </summary> public void LoadFilesToSampleBank(string[] filePaths, PathRelativeType pathType, GATSampleBank targetBank, GATDataAllocationMode allocationMode, OperationCompletedHandler onOperationCompleted, bool forceMono = false) { AGATLoadingOperation operation = new LoadingOperation(allocationMode, filePaths.Length, targetBank.AddLoadedFile, forceMono); int i; for (i = 0; i < filePaths.Length; i++) { operation.AddFile(filePaths[i], pathType); } operation.OnOperationCompleted = onOperationCompleted; EnqueueOperation(operation); }
void SetupGameLoadingOperations(IResolutionContainer container) { var manager = container.Resolve <ILoadingManager>(); //Example of how to append LoadingOperations to the LoadingManager. manager.GameOperationsSource = () => { _gameOperation = new LoadingOperation(0.0f, DoGameOperation); return(new List <ILoadingOperation> { _gameOperation }); }; }
void bw_Completed( object sender, RunWorkerCompletedEventArgs e ) { if( e.Error != null ) { _currentOperation.SetStatus( LoadOperationStatus.Failed ); } else if( e.Cancelled ) { _currentOperation.SetStatus( LoadOperationStatus.Cancelled ); _pendingOperations.Clear(); } if( _currentOperation.OnOperationCompleted != null ) _currentOperation.OnOperationCompleted( _currentOperation ); if( _pendingOperations.Count > 0 ) { _currentOperation = _pendingOperations.Dequeue(); _currentOperation.OperationWillStart(); _bw.RunWorkerAsync( _currentOperation ); } else { _bw = null; _currentOperation = null; } }
/// <summary> /// Convenience method for loading files asynchronously /// to a sample bank. This method instantiates, configures and /// enqueues a AGATLoadingOperation. Use NewOperation if you need /// more control over progress callbacks. /// </summary> public void LoadFilesToSampleBank( string[] filePaths, PathRelativeType pathType, GATSampleBank targetBank, GATDataAllocationMode allocationMode, OperationCompletedHandler onOperationCompleted, bool forceMono = false ) { AGATLoadingOperation operation = new LoadingOperation( allocationMode, filePaths.Length, targetBank.AddLoadedFile, forceMono ); int i; for( i = 0; i < filePaths.Length; i++ ) { operation.AddFile( filePaths[ i ], pathType ); } operation.OnOperationCompleted = onOperationCompleted; EnqueueOperation( operation ); }