public IAsyncResult BeginTranslate(IEnumerable<AutoTranslationItem> translationItems, string from, string to, AsyncCallback callback, object state) { if (asyncWorkerInstance != null) throw new InvalidOperationException("Another asynchronous process is in progress"); // do not translate this.stopRequested = false; asyncWorkerInstance = new TranslateInvoker(Translate); return asyncWorkerInstance.BeginInvoke(translationItems, from, to, callback, state); }
public IAsyncResult BeginTranslate(IEnumerable <AutoTranslationItem> translationItems, string from, string to, AsyncCallback callback, object state) { if (asyncWorkerInstance != null) { throw new InvalidOperationException("Another asynchronous process is in progress"); // do not translate } this.stopRequested = false; asyncWorkerInstance = new TranslateInvoker(Translate); return(asyncWorkerInstance.BeginInvoke(translationItems, from, to, callback, state)); }
public void EndTranslate(IAsyncResult result) { this.asyncWorkerInstance.EndInvoke(result); this.asyncWorkerInstance = null; }