那个网站可教做课件好,wordpress站点的根目录,工商管理局注册查询,网站做权重当我们在读取数据的时候#xff0c;或者处理大量数据的时候可能需要把鼠标设置为忙碌状态#xff0c;等待返回结果。下面的代码可以帮忙实现这点#xff1a; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using Syste…当我们在读取数据的时候或者处理大量数据的时候可能需要把鼠标设置为忙碌状态等待返回结果。下面的代码可以帮忙实现这点 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;namespace CursorThread
{public partial class Form1 : Form{public delegate int DoSomethingDelegate(int data);public Form1(){InitializeComponent();}static int DoSomething(int data){/// sumary/// Do something in this method/// /sumaryThread.Sleep(300);return data;}private void button1_Click(object sender, EventArgs e){this.Cursor Cursors.Default;DoSomethingDelegate d DoSomething;IAsyncResult ar d.BeginInvoke(100,null, null);while (true){this.Cursor Cursors.WaitCursor;if(ar.AsyncWaitHandle.WaitOne(50, false)){this.Cursor Cursors.Arrow;break;}}//Get the resultint result d.EndInvoke(ar);MessageBox.Show(result.ToString());}}
}这样在点击鼠标后鼠标会变成忙碌状态一直等待DoSomething这个方法调用结束然后变回箭头状态。 当然你也可以这样 // Set the status of the cursor
this.Cursor Cursor.Busy;// Do Something// Set the status of the cursor
this.Cursor Cursor.Arrow; 如果是在方法里面调用的话不能使用this关键字那你可以这样做 private void Method()
{ Curosor.Current Cursor.WaitCursor;/// Do SomethingCursor.Current Cursor.Arrow;
} 转载于:https://www.cnblogs.com/herbert/archive/2010/07/29/1787968.html