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

推荐订阅源

V
Vulnerabilities – Threatpost
U
Unit 42
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
F
Full Disclosure
月光博客
月光博客
Engineering at Meta
Engineering at Meta
博客园_首页
The Register - Security
The Register - Security
G
Google Developers Blog
The Cloudflare Blog
博客园 - Franky
K
Kaspersky official blog
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
C
Check Point Blog
NISL@THU
NISL@THU
AI
AI
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Vercel News
Vercel News
T
Tor Project blog
P
Privacy International News Feed
D
Docker
I
Intezer
L
LangChain Blog
P
Proofpoint News Feed
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
博客园 - 聂微东
AWS News Blog
AWS News Blog
Martin Fowler
Martin Fowler
P
Privacy & Cybersecurity Law Blog
V
V2EX
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
The Hacker News
The Hacker News
T
Tenable Blog
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog

博客园 - 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;
        }
    }
}