Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void IncrPaintQueue()
- {
- PaintQueue++;
- Thread.Sleep(100);
- }
- int PaintQueue = 0;
- private void SegmentList_SelectedIndexChanged(object sender, EventArgs e)
- {
- // We need to know how many threads this may possibly spawn.
- int MyQueue = PaintQueue;
- // Start a thread to increment the counter.
- Thread Th = new Thread(IncrPaintQueue);
- Th.IsBackground = true;
- Th.Start();
- Th.Join();
- // if I'm not the last thread, then just exit.
- // The last thread will do the right calculations.
- if (MyQueue != PaintQueue - 1)
- return;
- // Reset the PaintQueue counter.
- PaintQueue = 0;
- // ... do fancy calculations here...
- }
- public class SelectionEndListView : ListView
- {
- private System.Windows.Forms.Timer m_timer;
- private const int SELECTION_DELAY = 50;
- public SelectionEndListView()
- {
- m_timer = new Timer();
- m_timer.Interval = SELECTION_DELAY;
- m_timer.Tick += new EventHandler(m_timer_Tick);
- }
- protected override void OnSelectedIndexChanged(EventArgs e)
- {
- base.OnSelectedIndexChanged(e);
- // restart delay timer
- m_timer.Stop();
- m_timer.Start();
- }
- private void m_timer_Tick(object sender, EventArgs e)
- {
- m_timer.Stop();
- // Perform selection end logic.
- Console.WriteLine("Selection Has Ended");
- }
- }
- private void myListView_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
- {
- if (e.IsSelected)
- {
- // do your logic here
- }
- }
Add Comment
Please, Sign In to add comment