public InstantLookup(ActiveTextStrategy <T> strategy, int interval, NounRepository repo) { ActiveTextStrategy = strategy; enabled = false; paused = false; lookupTimer = new Timer(); lookupTimer.Interval = interval; lookupTimer.Tick += LookupActiveText; LemmaRepository = repo; }
public void LookupActiveText(object sender, EventArgs eventArgs) { bool timerRunning = lookupTimer.Enabled; lookupTimer.Stop(); string searchFor = ActiveTextStrategy.FindActiveWord(); if (searchFor.Length > 0) { BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += bgw_DoWork; worker.RunWorkerCompleted += bgw_WorkCompleted; SearchParams args = new SearchParams(); args.SearchLemma = searchFor; args.TargetWindow = ActiveTextStrategy.FindActiveDocument(); worker.RunWorkerAsync(args); } if (timerRunning) { lookupTimer.Start(); } }