• 大小: 334KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-14
  • 语言: C#
  • 标签: winform  

资源简介

winform的一个简单易用异步加载等待效果,调用方式: this.AsyncWaitDo(delegate{ //异步等待操作}, delegate{//回调操作}); this是要进行异步等待的窗体

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading;
using System.Windows.Forms;

namespace AsyncWaitDoTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void toolStripButton1_Click(object sender EventArgs e)
        {
            DataTable dt = null;

            this.AsyncWaitDo(delegate
            {
                Thread.Sleep(12000);
                Random rd = new Random();

                DataTable queryDt = new DataTable();
                queryDt.Columns.Add(“index“ typeof(int));
                queryDt.Columns.Add(“name“ typeof(string));
                for (int i = 0; i < 20; i++)
                {
                    DataRow dr = queryDt.NewRow();
                    dr[“index“] = rd.Next(1 20);
                    dr[“name“] = “name“ + i;
                    queryDt.Rows.Add(dr);
                }

                dt = queryDt;
            } delegate
            {
                bindingSource1.DataSource = dt;
            });
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-09-28 16:02  AsyncWaitDoTest\
     目录           0  2018-09-28 16:01  AsyncWaitDoTest\AsyncWaitDoTest\
     文件         887  2018-09-28 16:03  AsyncWaitDoTest\AsyncWaitDoTest.sln
     文件       47104  2018-09-28 16:05  AsyncWaitDoTest\AsyncWaitDoTest.suo
     文件        4189  2018-09-28 16:02  AsyncWaitDoTest\AsyncWaitDoTest\AsyncWaitDoTest.csproj
     目录           0  2018-09-28 13:26  AsyncWaitDoTest\AsyncWaitDoTest\bin\
     目录           0  2018-09-28 16:03  AsyncWaitDoTest\AsyncWaitDoTest\bin\Debug\
     文件      101888  2018-09-28 16:02  AsyncWaitDoTest\AsyncWaitDoTest\bin\Debug\ControlCopyTest.exe
     文件       40448  2018-09-28 16:02  AsyncWaitDoTest\AsyncWaitDoTest\bin\Debug\ControlCopyTest.pdb
     文件       11600  2018-09-28 16:05  AsyncWaitDoTest\AsyncWaitDoTest\bin\Debug\ControlCopyTest.vshost.exe
     文件         490  2010-03-17 22:39  AsyncWaitDoTest\AsyncWaitDoTest\bin\Debug\ControlCopyTest.vshost.exe.manifest
     文件         198  2018-09-28 14:05  AsyncWaitDoTest\AsyncWaitDoTest\bin\Debug\myFileName.xml
     目录           0  2018-09-28 13:26  AsyncWaitDoTest\AsyncWaitDoTest\bin\Release\
     文件        1178  2018-09-28 16:01  AsyncWaitDoTest\AsyncWaitDoTest\Form1.cs
     文件       13204  2018-09-28 16:01  AsyncWaitDoTest\AsyncWaitDoTest\Form1.Designer.cs
     文件       10698  2018-09-28 15:59  AsyncWaitDoTest\AsyncWaitDoTest\Form1.resx
     目录           0  2018-09-26 07:50  AsyncWaitDoTest\AsyncWaitDoTest\obj\
     目录           0  2018-09-26 07:50  AsyncWaitDoTest\AsyncWaitDoTest\obj\x86\
     目录           0  2018-09-28 16:02  AsyncWaitDoTest\AsyncWaitDoTest\obj\x86\Debug\
     文件       79519  2018-09-28 16:02  AsyncWaitDoTest\AsyncWaitDoTest\obj\x86\Debug\AsyncWaitDoTest.AsyncWaitControl.resources
     文件        1260  2018-09-28 16:05  AsyncWaitDoTest\AsyncWaitDoTest\obj\x86\Debug\AsyncWaitDoTest.csproj.FileListAbsolute.txt
     文件        1058  2018-09-28 16:02  AsyncWaitDoTest\AsyncWaitDoTest\obj\x86\Debug\AsyncWaitDoTest.csproj.GenerateResource.Cache
     文件        3483  2018-09-28 16:02  AsyncWaitDoTest\AsyncWaitDoTest\obj\x86\Debug\AsyncWaitDoTest.Form1.resources
     文件         180  2018-09-28 16:02  AsyncWaitDoTest\AsyncWaitDoTest\obj\x86\Debug\AsyncWaitDoTest.Properties.Resources.resources
     文件       79519  2018-09-28 15:57  AsyncWaitDoTest\AsyncWaitDoTest\obj\x86\Debug\ControlCopyTest.AsyncWaitControl.resources
     文件        1024  2018-09-28 16:01  AsyncWaitDoTest\AsyncWaitDoTest\obj\x86\Debug\ControlCopyTest.csproj.FileListAbsolute.txt
     文件        1058  2018-09-28 16:00  AsyncWaitDoTest\AsyncWaitDoTest\obj\x86\Debug\ControlCopyTest.csproj.GenerateResource.Cache
     文件      101888  2018-09-28 16:02  AsyncWaitDoTest\AsyncWaitDoTest\obj\x86\Debug\ControlCopyTest.exe
     文件        3483  2018-09-28 16:00  AsyncWaitDoTest\AsyncWaitDoTest\obj\x86\Debug\ControlCopyTest.Form1.resources
     文件       40448  2018-09-28 16:02  AsyncWaitDoTest\AsyncWaitDoTest\obj\x86\Debug\ControlCopyTest.pdb
     文件         180  2018-09-28 15:57  AsyncWaitDoTest\AsyncWaitDoTest\obj\x86\Debug\ControlCopyTest.Properties.Resources.resources
............此处省略16个文件信息

评论

共有 条评论