惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
V
Vulnerabilities – Threatpost
Google Online Security Blog
Google Online Security Blog
Hugging Face - Blog
Hugging Face - Blog
L
LINUX DO - 热门话题
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
D
Docker
C
Cyber Attacks, Cyber Crime and Cyber Security
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
T
Tenable Blog
P
Privacy International News Feed
Google DeepMind News
Google DeepMind News
小众软件
小众软件
Cisco Talos Blog
Cisco Talos Blog
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
A
Arctic Wolf
C
Cybersecurity and Infrastructure Security Agency CISA
C
Cisco Blogs
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
The Hacker News
The Hacker News
Project Zero
Project Zero
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Threatpost
V
Visual Studio Blog
The GitHub Blog
The GitHub Blog
The Cloudflare Blog
Last Week in AI
Last Week in AI
Jina AI
Jina AI
Cyberwarzone
Cyberwarzone
The Register - Security
The Register - Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
Vercel News
Vercel News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
MongoDB | Blog
MongoDB | Blog
U
Unit 42
Scott Helme
Scott Helme
A
About on SuperTechFans
WordPress大学
WordPress大学
F
Fortinet All Blogs
大猫的无限游戏
大猫的无限游戏
G
GRAHAM CLULEY
Latest news
Latest news
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
Schneier on Security

博客园 - StephenJu

EntLib--Unity Application Block 1.x DevExpress杂项 .Net异步机制 按s1_Name+uuid为一组拆分DS 枚举 分割dataset:待改进... 序列化 DataGridViewComboBoxColumn的使用 datagridview数据验证 通过关键字查找到dgv相关记录后定位 禁止一个程序启动多个实例 将文本文件的内容写进某个表中 获取Assembly的运行路径 获取ArrayList中的数据(foreach) 关于DataTable里大批量查找的更快速的方法 抽象类 IO DynamicCreateMenu DataTable的简单方法
简单的异步调用
StephenJu · 2009-09-10 · via 博客园 - StephenJu

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace WinAppAsync
{
    
public partial class Form1 : Form
    {
        
public Form1()
        {
            InitializeComponent();
        }
private void btnLoad_Click(object sender, EventArgs e)
        {
            
this.Text = "正在加载";
            
//异步执行
            LoadDataHandlerInstance = new LoadDataHandler(CreateData);
            AsyncCallback callBackMethod 
= new AsyncCallback(CallBackLoad);
            LoadDataHandlerInstance.BeginInvoke(callBackMethod, LoadDataHandlerInstance);
        }
public delegate DataTable LoadDataHandler();
        
public LoadDataHandler LoadDataHandlerInstance = null;
        
private DataTable CreateData()
        {
            DataTable dt 
= new DataTable();
            dt.Columns.Add(
"Id"typeof(string));
            dt.Columns.Add(
"Name"typeof(string));
            dt.Columns.Add(
"Address"typeof(string));for (int i = 0; i < 800000; i++)
            {
                DataRow row 
= dt.NewRow();
                row[
"Id"= i.ToString();
                row[
"Name"= "Name_" + i.ToString();
                row[
"Address"= "Address_" + i.ToString();
                dt.Rows.Add(row);
            }
            
return dt;
        }
        
public void CallBackLoad(IAsyncResult result)
        {
            LoadDataHandler loadInstance 
= (LoadDataHandler)result.AsyncState;
            DataTable dt 
= loadInstance.EndInvoke(result);

            bindGridHandlerInstance 

= new BindGridHandler(BindGrid);
            
this.dgv.BeginInvoke(bindGridHandlerInstance, new object[] { dt });//执行控件的Invoke或BeginInvoke以修改主线程上的属性
        }public delegate void BindGridHandler(DataTable dt);
        
public BindGridHandler bindGridHandlerInstance = null;
        
private void BindGrid(DataTable dt)
        {
            
this.dgv.DataSource = dt;
        }
    }
}