資源簡介
用c#編寫的程序,讀取串口的數據,同時寫入SQLServer網絡數據庫,這個過程都是多線程的。

代碼片段和文件信息
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.IO;
using?System.IO.Ports;
using?System.Data.SqlClient;
using?System.Configuration;
using?System.Reflection;
using?System.Data.SQLite;
using?System.Threading;
using?System.Runtime.InteropServices;
namespace?SerialPortRSTool
{
????public?partial?class?Form1?:?Form
????{
????????static?log4net.ILog?LOG?=?log4net.LogManager.GetLogger(Methodbase.GetCurrentMethod().DeclaringType);
????????[DllImport(“kernel32“)]
????????private?static?extern?long?WritePrivateProfileString(string?section?string?key?string?val?string?filePath);
????????[DllImport(“kernel32“)]
????????private?static?extern?int?GetPrivateProfileString(string?section?string?key?string?def?StringBuilder?retVal?int?size?string?filePath);
????????SerialPort?sp?=?new?SerialPort();
????????List?buffer?=?new?List(4096);
????????Queue?dataList?=?new?Queue();
????????delegate?void?Display(String?text);
????????SqlConnection?cnnSQLServer;
????????SQLiteConnection?cnnSQLite;
????????Thread?trdDataReceive;
????????Thread?trdDataShow;
????????Thread?trdSQLite;
????????Thread?trdSQLServer;
????????private?bool?bWindowCreate?=?true;
????????private?bool?bListen1?=?false;
????????private?bool?bListen2?=?false;
????????private?bool?bListen3?=?false;
????????private?bool?bListen4?=?false;
????????private?bool?bWriteINI?=?false;
????????private?bool?bInitial?=?false;
????????private?bool?bOpening?=?false;
????????private?bool?bDelete?=?false;
????????private?bool?bShowing?=?false;
????????String?sSQLite?=?““;
????????String?sSQLServer?=?““;
????????String?sqlite_table?=?““;
????????String?sqlS_table?=?““;
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????cbSerialPort.DropDownstyle?=?ComboBoxstyle.DropDown;
????????????cbSerialPort.Items.Add(“COM1“);
????????????cbSerialPort.Items.Add(“COM2“);
????????????cbSerialPort.Items.Add(“COM3“);
????????????cbSerialPort.Items.Add(“COM4“);
????????????cbSerialPort.Items.Add(“COM5“);
????????????cbSerialPort.Items.Add(“COM6“);
????????????cbSerialPort.Items.Add(“COM7“);
????????????cbSerialPort.Items.Add(“COM8“);
????????????cbSerialPort.Items.Add(“COM9“);
????????????cbBaudrate.DropDownstyle?=?ComboBoxstyle.DropDown;
????????????cbBaudrate.Items.Add(“9600“);
????????????cbBaudrate.Items.Add(“14400“);
????????????cbBaudrate.Items.Add(“19200“);
????????????cbBaudrate.Items.Add(“38400“);
????????????cbBaudrate.Items.Add(“56000“);
????????????cbBaudrate.Items.Add(“57600“);
????????????cbBaudrate.Items.Add(“115200“);
????????????cbBaudrate.Items.Add(“128000“);
????????????cbDatabit.DropDownstyle?=?ComboBoxstyle.DropDown;
????????????cbDatabit.It
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1022??2013-07-16?15:29??SerialPortRSTool\SerialPortRSTool\App.config
?????文件????????239??2013-08-12?18:40??SerialPortRSTool\SerialPortRSTool\bin\Debug\config.ini
?????文件??????13652??2014-09-18?14:48??SerialPortRSTool\SerialPortRSTool\bin\Debug\Log\20140918.txt
?????文件?????286720??2013-07-10?11:32??SerialPortRSTool\SerialPortRSTool\bin\Debug\log4net.dll
?????文件?????124416??2014-09-18?14:45??SerialPortRSTool\SerialPortRSTool\bin\Debug\SerialPortRSTool.exe
?????文件???????1022??2013-07-16?15:29??SerialPortRSTool\SerialPortRSTool\bin\Debug\SerialPortRSTool.exe.config
?????文件??????46592??2014-09-18?14:45??SerialPortRSTool\SerialPortRSTool\bin\Debug\SerialPortRSTool.pdb
?????文件??????11600??2014-09-18?14:48??SerialPortRSTool\SerialPortRSTool\bin\Debug\SerialPortRSTool.vshost.exe
?????文件???????1022??2013-07-16?15:29??SerialPortRSTool\SerialPortRSTool\bin\Debug\SerialPortRSTool.vshost.exe.config
?????文件????????490??2010-03-17?22:39??SerialPortRSTool\SerialPortRSTool\bin\Debug\SerialPortRSTool.vshost.exe.manifest
?????文件?????904704??2010-04-18?13:58??SerialPortRSTool\SerialPortRSTool\bin\Debug\System.Data.SQLite.dll
?????文件??????57226??2010-04-18?13:34??SerialPortRSTool\SerialPortRSTool\bin\Debug\System.Data.SQLite.lib
?????文件?????184765??2010-04-18?13:34??SerialPortRSTool\SerialPortRSTool\bin\Debug\System.Data.SQLite.xm
?????文件??????????1??2013-07-15?12:01??SerialPortRSTool\SerialPortRSTool\ClassDiagram1.cd
?????文件??????27493??2013-08-12?19:19??SerialPortRSTool\SerialPortRSTool\Form1.cs
?????文件??????26592??2013-08-12?19:13??SerialPortRSTool\SerialPortRSTool\Form1.Designer.cs
?????文件?????146206??2013-08-12?19:13??SerialPortRSTool\SerialPortRSTool\Form1.resx
?????文件???????4501??2013-07-13?15:44??SerialPortRSTool\SerialPortRSTool\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件???????6630??2014-09-18?14:45??SerialPortRSTool\SerialPortRSTool\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件????????678??2014-09-18?14:45??SerialPortRSTool\SerialPortRSTool\obj\x86\Debug\GenerateResource.read.1.tlog
?????文件????????822??2014-09-18?14:45??SerialPortRSTool\SerialPortRSTool\obj\x86\Debug\GenerateResource.write.1.tlog
?????文件??????25136??2014-09-18?14:45??SerialPortRSTool\SerialPortRSTool\obj\x86\Debug\ResolveAssemblyReference.cache
?????文件???????1846??2014-09-18?14:48??SerialPortRSTool\SerialPortRSTool\obj\x86\Debug\SerialPortRSTool.csproj.FileListAbsolute.txt
?????文件?????124416??2014-09-18?14:45??SerialPortRSTool\SerialPortRSTool\obj\x86\Debug\SerialPortRSTool.exe
?????文件??????93432??2014-09-18?14:45??SerialPortRSTool\SerialPortRSTool\obj\x86\Debug\SerialPortRSTool.Form1.resources
?????文件??????46592??2014-09-18?14:45??SerialPortRSTool\SerialPortRSTool\obj\x86\Debug\SerialPortRSTool.pdb
?????文件????????180??2014-09-18?14:45??SerialPortRSTool\SerialPortRSTool\obj\x86\Debug\SerialPortRSTool.Properties.Resources.resources
?????文件???????4608??2013-07-15?12:07??SerialPortRSTool\SerialPortRSTool\obj\x86\Debug\TempPE\Properties.Resources.Designer.cs.dll
?????文件????????582??2013-07-16?15:26??SerialPortRSTool\SerialPortRSTool\Program.cs
?????文件???????1431??2013-07-15?16:10??SerialPortRSTool\SerialPortRSTool\Properties\AssemblyInfo.cs
............此處省略20個文件信息
- 上一篇:gamma函數C#
- 下一篇:CefSharp.WinForms 支持mp4
評論
共有 條評論