/// <summary> /// Upload file and start recognition asynchronously /// Performs callbacks: /// UploadFileCompleted /// TaskProcessingCompleted /// </summary> private void processFileAsync(string filePath, IProcessingSettings settings, object taskId) { // Create an AsyncOperation for taskId. AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(taskId); // Multiple threads will access the task dictionary, // so it must be locked to serialize access. lock (processJobs.SyncRoot) { if (processJobs.Contains(taskId)) { throw new ArgumentException( "Task ID parameter must be unique", "taskId"); } processJobs[taskId] = asyncOp; } // Start the asynchronous operation. processFileWorkerEventHandler workerDelegate = new processFileWorkerEventHandler(processFileWorker); workerDelegate.BeginInvoke( filePath, settings, asyncOp, null, null); }
/// <summary> /// Upload file and start recognition asynchronously /// Performs callbacks: /// UploadFileCompleted /// TaskProcessingCompleted /// </summary> private void processFileAsync(string filePath, IProcessingSettings settings, object taskId) { // Create an AsyncOperation for taskId. AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(taskId); // Multiple threads will access the task dictionary, // so it must be locked to serialize access. lock (processJobs) { if (processJobs.ContainsKey(taskId)) { throw new ArgumentException( "Task ID parameter must be unique", "taskId"); } processJobs[taskId] = asyncOp; } // Start the asynchronous operation. processFileWorkerEventHandler workerDelegate = new processFileWorkerEventHandler(processFileWorker); workerDelegate.BeginInvoke( filePath, settings, asyncOp, null, null); }