Launch BackroundWorker, which will exit when the mouse is released. Set the flag with the mouse event, and also periodically check in the BackgroundWorker DoWork function. Make sure you use lock {} to access the flag.
Edit: if you want to access something in the user interface thread, use Dispatcher.BeginInvoke, for example:
Dispatcher.BeginInvoke(new ThreadStart(delegate { ComboBoxItem selItem = ComboboxConnectString.SelectedItem as ComboBoxItem; if (selItem != null && selItem.Tag is string) ComboboxConnectString.Text = (string)selItem.Tag; }));
Ed bayiates
source share