void Win7UIAClientForm_FormClosed(object sender, FormClosedEventArgs e) { if (_synth != null) { _synth.SpeakAsyncCancelAll(); _synth = null; } if (_highlight != null) { _highlight.Uninitialize(); _highlight = null; } if (_sampleFocusEventHandler != null) { _sampleFocusEventHandler.Uninitialize(); _sampleFocusEventHandler = null; } // Give any background threads created on startup a chance to close down gracefully. Thread.Sleep(200); }
void InitializeSample() { // Initialize the highlighting used to magnify the element with focus. _highlight = new Highlight(); _highlight.Initialize(); try { _synth = new SpeechSynthesizer(); } catch { // Allow this sample to run even if speech is not available. _synth = null; } // Initialize the event handler which is called when focus changes. SampleUIEventHandlerDelegate sampleUIEventHandlerDelegate = new SampleUIEventHandlerDelegate(HandleEventOnUIThread); _sampleFocusEventHandler = new SampleFocusEventHandler(this, sampleUIEventHandlerDelegate); // Now tell the sample event handler to register for events from UIA. _sampleFocusEventHandler.StartEventHandler(); }
///////////////////////////////////////////////////////////////////////////////////////////////// // // s_ThreadProc() // // Static entry point for the thread on which the event handlers will be added and removed. // ///////////////////////////////////////////////////////////////////////////////////////////////// public static void s_ThreadProc(object data) { SampleFocusEventHandler eventHandler = (SampleFocusEventHandler)data; eventHandler.ThreadProc(); }