-
大小: 721.46 KB文件类型: .rar金币: 2下载: 0 次发布日期: 2024-07-28
- 语言: C#
- 标签: 101 C# WindowsForms 微软
资源简介
这是微软给的类似于SDK中事例代码的程序,总共101个,这是Windows Forms篇,总共四个。
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace AsynchronousTasks
{
public partial class MainForm : Form
{
private System.ComponentModel.BackgroundWorker backgroundCalculator;
public MainForm()
{
InitializeComponent();
// Prepare the background worker for asynchronous prime number calculation
backgroundCalculator = new BackgroundWorker();
// Specify that the background worker provides progress notifications
backgroundCalculator.WorkerReportsProgress = true;
// Specify that the background worker supports cancellation
backgroundCalculator.WorkerSupportsCancellation = true;
// The DoWork event handler is the main work function of the background thread
backgroundCalculator.DoWork += new DoWorkEventHandler(backgroundCalculator_DoWork);
// Specify the function to use to handle progress notifications
backgroundCalculator.ProgressChanged += new ProgressChangedEventHandler(backgroundCalculator_ProgressChanged);
// Specify the function to run when the background worker finishes
// There are three conditions possible that should be handled in this function:
// 1. The work completed successfully
// 2. The work aborted with errors
// 3. The user cancelled the process
backgroundCalculator.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundCalculator_RunWorkerCompleted);
updateStatus(String.Empty);
}
// This region implements calculating primes in a synchronous fashion
#region Synchronous calculation
// Synchronously calculate the next prime number
// starting with a specified number.
private int getNextPrimeSync(int start)
{
int percentComplete = 0;
start++;
while (!isPrime(start))
{
// start was not prime. Try next number higher.
start++;
// Report progress
percentComplete++;
// With prime number calculation there is no way to determine
// how far along you are so simply move the progress bar
// and reset as needed
updateProgress(percentComplete % 100);
}
return start;
}
private void nextPrimeButton_Click(object sender EventArgs e)
{
updateStatus(“Calculating...“);
int start;
Int32.TryParse(textBoxPrime.Text out start );
if (start == 0)
{
reportError(“The number must be a valid integer“);
}
else
{
try
{
int prime = getNextPrimeSync(start);
reportPrime(prime)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3037 2005-06-29 12:28 Windows Forms\AsynchronousTasks\AsynchronousTasks\AsynchronousTasks.csproj
文件 173 2005-06-29 12:28 Windows Forms\AsynchronousTasks\AsynchronousTasks\AsynchronousTasks.csproj.user
文件 24576 2007-08-18 15:40 Windows Forms\AsynchronousTasks\AsynchronousTasks\bin\Debug\AsynchronousTasks.exe
文件 32256 2007-08-18 15:40 Windows Forms\AsynchronousTasks\AsynchronousTasks\bin\Debug\AsynchronousTasks.pdb
文件 5632 2005-09-23 06:56 Windows Forms\AsynchronousTasks\AsynchronousTasks\bin\Debug\AsynchronousTasks.vshost.exe
目录 0 2007-08-18 15:34 Windows Forms\AsynchronousTasks\AsynchronousTasks\bin\Debug
目录 0 2007-08-18 15:33 Windows Forms\AsynchronousTasks\AsynchronousTasks\bin
文件 8168 2007-08-18 15:40 Windows Forms\AsynchronousTasks\AsynchronousTasks\Form1.cs
文件 7828 2007-08-18 15:40 Windows Forms\AsynchronousTasks\AsynchronousTasks\Form1.Designer.cs
文件 6017 2007-08-18 15:40 Windows Forms\AsynchronousTasks\AsynchronousTasks\Form1.resx
文件 341 2007-08-18 15:41 Windows Forms\AsynchronousTasks\AsynchronousTasks\obj\AsynchronousTasks.csproj.FileList.txt
文件 842 2007-08-18 15:40 Windows Forms\AsynchronousTasks\AsynchronousTasks\obj\Debug\AsynchronousTasks.csproj.GenerateResource.Cache
文件 24576 2007-08-18 15:40 Windows Forms\AsynchronousTasks\AsynchronousTasks\obj\Debug\AsynchronousTasks.exe
文件 180 2007-08-18 15:40 Windows Forms\AsynchronousTasks\AsynchronousTasks\obj\Debug\AsynchronousTasks.MainForm.resources
文件 32256 2007-08-18 15:40 Windows Forms\AsynchronousTasks\AsynchronousTasks\obj\Debug\AsynchronousTasks.pdb
文件 180 2007-08-18 15:34 Windows Forms\AsynchronousTasks\AsynchronousTasks\obj\Debug\AsynchronousTasks.Properties.Resources.resources
目录 0 2007-08-18 15:33 Windows Forms\AsynchronousTasks\AsynchronousTasks\obj\Debug\TempPE
目录 0 2007-08-18 15:40 Windows Forms\AsynchronousTasks\AsynchronousTasks\obj\Debug
目录 0 2007-08-18 15:34 Windows Forms\AsynchronousTasks\AsynchronousTasks\obj
文件 542 2005-06-29 12:28 Windows Forms\AsynchronousTasks\AsynchronousTasks\Program.cs
文件 1281 2005-06-29 12:28 Windows Forms\AsynchronousTasks\AsynchronousTasks\Properties\AssemblyInfo.cs
文件 2368 2005-06-29 12:28 Windows Forms\AsynchronousTasks\AsynchronousTasks\Properties\Resources.Designer.cs
文件 5612 2005-06-29 12:28 Windows Forms\AsynchronousTasks\AsynchronousTasks\Properties\Resources.resx
文件 1119 2005-06-29 12:28 Windows Forms\AsynchronousTasks\AsynchronousTasks\Properties\Settings.Designer.cs
文件 249 2005-06-29 12:28 Windows Forms\AsynchronousTasks\AsynchronousTasks\Properties\Settings.settings
目录 0 2007-08-18 10:12 Windows Forms\AsynchronousTasks\AsynchronousTasks\Properties
文件 900 2005-06-29 12:28 Windows Forms\AsynchronousTasks\AsynchronousTasks\README.htm
目录 0 2007-08-18 15:40 Windows Forms\AsynchronousTasks\AsynchronousTasks
文件 940 2005-06-29 12:28 Windows Forms\AsynchronousTasks\AsynchronousTasks.sln
..A..H. 12288 2007-08-18 15:41 Windows Forms\AsynchronousTasks\AsynchronousTasks.suo
............此处省略367个文件信息
- 上一篇:c#编写的连连看程序
- 下一篇:C#异构数据库转换工具源码
相关资源
- C#异构数据库转换工具源码
- c#编写的连连看程序
- C#如何模拟键盘输入
- 组合 算法 C# 背包问题
- C#中视图和存储过程应用
- C#使用剪切板粘贴数据
- C# TcpListener 例程(源码)
- C#实例程序100例子
- C#设计高精度语音识别程序
- winform(c#)最全73种非常漂亮界面样式
- 图书管理系统-----------C# 版
- C#串口通信程序(VS2010)(serialPort组
- C#鼠标自动点击软件
- C#实现pos打机的附ECS/POS说明书)
- c# 带树形显示的下拉框
- 最新Trimble全站仪串口通讯
- 呕心沥血之作。C#矩阵类matrix
- C#Oracle数据库备份
- C#(Winfrom)窗体传值问题(子窗体回
- c# 委托、父窗体传值到子窗体DEMO,完
- C#打印条码源码
- JSON C#与服务器通讯
- C#的服务器程序
- C# Socket TCP通信
- c#实时获取温湿度
- c#实现Modbus tcp客户端
- C#利用baslerSDK实现相机采集图像
- 360手机助手界面C#
- C#和西门子CPU进行S7通讯
- C#实现登录注册(SQL)
评论
共有 条评论