如何知道用户是否正在滚动datagridview

Ank*_*Roy 9 c# multithreading datagridview

我想知道用户是否正在滚动DataGridView.

当用户滚动DataGridView时,我希望暂停正在运行的线程,并在用户停止滚动时立即恢复该线程.

任何帮助都将深深感激.

非常感谢 :)

更新:

对于我的工作,代码在这里: - 滚动时通过线程更新DataGridView

zab*_*lus 2

public class DataGridViewEx : DataGridView
    {
        private const int WM_HSCROLL = 0x0114;
        private const int WM_VSCROLL = 0x0115;
        private const int WM_MOUSEWHEEL = 0x020A;

        public event ScrollEventHandler ScrollEvent;
        const int SB_HORZ = 0;
        const int SB_VERT = 1;
        public int ScrollValue;
        [DllImport("User32.dll")]
        static extern int GetScrollPos(IntPtr hWnd, int nBar);
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
            if (m.Msg == WM_VSCROLL ||
                m.Msg == WM_MOUSEWHEEL)
                if (ScrollEvent != null)
                {
                    this.ScrollValue = GetScrollPos(Handle, SB_VERT);
                    ScrollEventArgs e = new ScrollEventArgs(ScrollEventType.ThumbTrack, ScrollValue);
                    this.ScrollEvent(this, e);
                }            
        }
    }
Run Code Online (Sandbox Code Playgroud)

将挂起代码添加到 ScrollEvent 事件的处理程序中