BeginInvoke 激活表单
我有一个用 C# 编写的 WinForms 应用程序。打开时出现的第一个屏幕是仪表板屏幕,可能需要一些时间才能加载。使用委托上的 BeginInvoke 调用数据加载方法。那部分很好,我的问题是当我想将读取的数据加载到某些网格中时。让我回到 UI 线程的代码看起来像这样,
BeginInvoke(new Action<DashboardDataInfo, int>(LoadDashboardData), data, outbox);
这一切都没有错误地发生。我的问题是仪表板表单将跳到屏幕顶部。如果数据加载花费了足够长的时间,用户可能已经进入应用程序中的另一个(所以这真的很烦人)。除了分配一些 DataGridView 控件的 DataSource 属性之外,LoadDashboardData 方法没有做太多事情。
I have a WinForms application written in C#. The first screen to appear when it opens is a dashboard screen that can take some time to load. The data loading method is called using BeginInvoke on delegate. That part is fine, my problem is when I want to load the read data into some grids. The code to get me back to my UI thread looks like so
BeginInvoke(new Action<DashboardDataInfo, int>(LoadDashboardData), data, outbox);
This all happens without error. My problem is the dashboard Form will jump to the top of the screen. If data loading has taken long enough the user could be already onto another from in the app (so this is really annoying). The LoadDashboardData method doesn't do much besides assign the DataSource property of a few DataGridView controls.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论