-
C# 创建有参、无参数等多线程操作实例
C# 多线程操作实例,获取指定进程的进程详细信息、获取指定进程的模块详细信息、创建无参数的多线程应用程序、创建带参数的多线程应用程序、创建共享线程模拟资源共享、创建子线程更新主线程数据等,部分代码分享如下:
if (MyThread.ThreadState == ThreadState.Terminated)
MyData += "
当前状态:已完成执行并已退出";
if (MyThread.ThreadState == ThreadState.Transition)
MyData += "
当前状态:在可以执行前等待处理器之外的资源";
if (MyThread.ThreadState == ThreadState.Unknown)
MyData += "
当前状态:状态未知";
if (MyThread.ThreadState == ThreadState.Wait)
MyData += "
当前状态:正在等待外围操作完成或等待资源释放";
if (MyThread.WaitReason == ThreadWaitReason.EventPairHigh)
MyData += "
等待原因:线程正在等待事件对高";
if (MyThread.WaitReason == ThreadWaitReason.EventPairLow)
MyData += "
等待原因:线程正在等待事件对低";
if (MyThread.WaitReason == ThreadWaitReason.ExecutionDelay)
MyData += "
等待原因:线程执行延迟";
if (MyThread.WaitReason == ThreadWaitReason.Executive)
MyData += "
等待原因:线程正在等待计划程序";
if (MyThread.WaitReason == ThreadWaitReason.FreePage)
MyData += "
等待原因:线程正在等待可用的虚拟内存页";
if (MyThread.WaitReason == ThreadWaitReason.LpcReceive)
- 2022-04-18 07:37:09下载
- 积分:1
-
C# 实现凹凸按钮(立体按钮效果)
Visual C# 实现凹凸按钮(立体按钮效果),鼠标放在按钮上,按下鼠标左键,即可看到凹凸效果:
private void Window_Loaded(object sender, RoutedEventArgs e)
{//(上凸效果)
BevelBitmapEffect MyBevelEffect = new BevelBitmapEffect();
MyBevelEffect.BevelWidth = 20;
MyBevelEffect.EdgeProfile = EdgeProfile.CurvedIn;
MyBevelEffect.LightAngle = 320;
MyBevelEffect.Relief = 0.4;
MyBevelEffect.Smoothness = 0.4;
this.button1.BitmapEffect = MyBevelEffect;
bShift = true;
}
private void button1_Click(object sender, RoutedEventArgs e)
{//凹凸显示按钮(下凸效果)
if (bShift)
{
BevelBitmapEffect MyBevelEffect = new BevelBitmapEffect();
MyBevelEffect.BevelWidth = 20;
this.button1.BitmapEffect = MyBevelEffect;
bShift = false;
}
else
{
BevelBitmapEffect MyBevelEffect = new BevelBitmapEffect();
MyBevelEffect.BevelWidth = 20;
MyBevelEffect.EdgeProfile = EdgeProfile.CurvedIn;
MyBevelEffect.Ligh
- 2022-04-20 03:11:38下载
- 积分:1
-
C# 使用字符串数组创建一组单选框数据
C# 基于字符串数组创建一组单选按钮的例子,附上了例子源代码,大家可了解C#字符串数组的简单应用。
以下是例子中的代码,运行后可见如下图所示的图片效果:
//基于字符串数组创建一组单选按钮
string[] MyArray = new string[4];
MyArray[0] = "渝北区";
MyArray[1] = "巴南区";
MyArray[2] = "长寿区";
MyArray[3] = "南岸区";
RadioButton[] MyRadioButtons =new RadioButton[4];
for (int i = 0; i < 4; ++i)
{
MyRadioButtons[i] = new RadioButton();
MyRadioButtons[i].Text = MyArray[i];
MyRadioButtons[i].Location = new System.Drawing.Point(
10, 20 + i * 20);
this.groupBox1.Controls.Add(MyRadioButtons[i]);
}
this.groupBox1.Text = "请评选全市卫生城区:";
- 2022-02-27 00:14:46下载
- 积分:1
-
Visual C# 自动识别Access数据库路径
Visual C# 自动识别Access 2000数据库路径,当然不仅限于Access2000,Access2007版本也可以,此源码仅是示例,当然打开程序后,程序会自动搜索Access路径,连接之后自动打开程序。大致的实现方法,可参考下述代码:
string strPath = Application.StartupPath + " est.mdb";//得到数据库路径
string ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + strPath;//创建连接字符串
OleDbDataAdapter OleDatOleDat = new OleDbDataAdapter(//创建数据适配器对象
"select * from 帐目", ConStr);
OleDatOleDat.Fill(dt);//填充数据表
count = dt.Rows.Count;
textBox1.Text = dt.Rows[0][0].ToString();//显示数据表中数据
textBox2.Text = dt.Rows[0][1].ToString();//显示数据表中数据
textBox3.Text = dt.Rows[0][2].ToString();//显示数据表中数据
textBox4.Text = dt.Rows[0][3].ToString();//显示数据表中数据
- 2022-03-24 00:39:43下载
- 积分:1
-
某超市进销存管理系统(C++_Oracle开发源码)
某超市进销存管理系统(C++_Oracle开发源码)
- 2022-11-23 22:55:04下载
- 积分:1
-
C# 将图像控件的定义导出为XAML文件
C# 将图像控件的定义导出为XAML文件,支持的图像文件:图像文件(JPeg,Gif,Bmp,etc,tiff,png)等。
string MyXAML= System.Windows.Markup.XamlWriter.Save(this.image1);
if (System.IO.File.Exists("MyXaml.xaml"))
System.IO.File.Delete("MyXaml.xaml");
System.IO.File.AppendAllText("MyXaml.xaml", MyXAML);
MessageBox.Show(MyXAML, "MyXaml.xaml文件的内容", MessageBoxButton.OK);
- 2022-04-14 09:51:54下载
- 积分:1
-
C#以二进制格式打开和保存文件
C#使用BinaryWriter、BinaryReader对象分别保存和读取二进制文件,程序分两部分,先来看第一部分:
C#以二进制格式保存文件:设置保存文件的格式:
saveFileDialog1.Filter = "二进制文件(*.dat)|*.dat";
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
//使用“另存为”对话框中输入的文件名实例化FileStream对象
FileStream myStream = new FileStream(saveFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);
//使用FileStream对象实例化BinaryWriter二进制写入流对象
BinaryWriter myWriter = new BinaryWriter(myStream);
//以二进制方式向创建的文件中写入内容
myWriter.Write(textBox1.Text);
//关闭当前二进制写入流
myWriter.Close();
//关闭当前文件流
myStream.Close();
textBox1.Text = string.Empty;
}
打开文件时同样也是以二进制来打开读取文件内容:
//设置打开文件的格式
openFileDialog1.Filter = "二进制文件(*.dat)|*.dat";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = string.Empty;
//使用“打开”对话框中选择的文件名实例化FileStream对象
FileStream myStream = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read);
//使用FileStream对象实例化BinaryRea
- 2022-02-14 18:03:07下载
- 积分:1
-
Visual C# Timer 构建的进度条演示
Visual C# Timer 构建的进度条演示,progressBar进度条的建立与使用,简单的范例,面向C#的初级开发者,希望初学者能够熟悉Loading如何创作哦,以下代码可以参考:
private void timer1_Tick(object sender, EventArgs e)
{
//使用三元运算符为progressBar的Value值自加1
progressBar1.Value = ++progressBar1.Value > 1000 - 1 ? 0 : progressBar1.Value;
//显示载入百分比
label2.Text = string.Format("已经载入{0}%", (int)(progressBar1.Value / 1000f * 100));
}
- 2022-04-16 04:00:01下载
- 积分:1
-
C# DataGridView初级操作范例
这是一个C# DataGridView初级操作范例,演示了连接数据库、读取数据库、移动数据库指针到下一条、上一条记录的操作,以及将数据绑定到DataGridView控件中显示的整个过程,比较基础级的C#源码,因此希望新手参考:
private void shippersDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
{//如果错误发生在提交操作过程中,则在 MessageBox 中显示该错误
if (e.Exception != null && e.Context == DataGridViewDataErrorContexts.Commit)
{//测试时在Phone列中输入一个超长的字符串
MessageBox.Show(e.Exception.Message, "信息提示", MessageBoxButtons.OK);
}
}
- 2022-01-22 02:28:43下载
- 积分:1
-
二维码生成的C源代码(QRCODE)
二维码(QRCODE)生成的C源代码,比较完整,测试可用
- 2022-01-30 22:00:53下载
- 积分:1