数据库的多线程调用

做了个关于多线程连接存储数据库的程序,但是总感觉在数据库的open()上感觉有点乱乱的!希望各位看官给点意见啊!
None.gif using  System;
None.gif
using  System.Drawing;
None.gif
using  System.Collections; // Arrylist
None.gif
using  System.ComponentModel;
None.gif
using  System.Windows.Forms;
None.gif
using  System.Data;
None.gif
using  System.Runtime.InteropServices;
None.gif
using  System.Threading;
None.gif
using  System.Data.SqlClient;
None.gif
namespace  ground
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// 
InBlock.gif    
/// Form1 的摘要说明。
ExpandedSubBlockEnd.gif    
/// 

InBlock.gif    public class Form1 : System.Windows.Forms.Form
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif        
data define#region data define
InBlock.gif        
private System.Windows.Forms.Button button1;
InBlock.gif        
private System.Windows.Forms.Button button2;
InBlock.gif        
private System.Windows.Forms.Button button3;
InBlock.gif        
private System.Windows.Forms.Button button4;
InBlock.gif        
private System.Windows.Forms.Button button5;
InBlock.gif        
private System.Windows.Forms.ProgressBar progressBar1;
InBlock.gif        
private System.Windows.Forms.Label label1;
InBlock.gif        
private System.Windows.Forms.Button button6;
InBlock.gif        
private System.ComponentModel.IContainer components;
InBlock.gif
InBlock.gif        
//设定系统时间
InBlock.gif
        System.DateTime currentTime=new System.DateTime();
InBlock.gif        System.DateTime currentTime1
=new System.DateTime();
InBlock.gif        System.DateTime currentTime0
=new System.DateTime();
InBlock.gif
InBlock.gif        
//定义插入语句
InBlock.gif
        string insert_mq="INSERT INTO  MQ_DATA (MQ_DATA,OFFSET,TIME,ID) VALUES(ch[i][0],ch[i][1],ch[i][2])";
InBlock.gif        
string insert_zlj="INSERT INTO ZLJ_DATA (ZLJ_DATA,OFFSET,TIME) VALUES(ch[i][0],ch[i][1],ch[i][2])";
InBlock.gif        
string insert_return="INSERT INTO  RETURN_MQ_DATA (RETURN_MQ_DATA,OFFSET,TIME) VALUES(ch[i][0],ch[i][1],ch[i][2])";
InBlock.gif        
string insert_rc="INSERT INTO  RC_DATA (RC_DATA,OFFSET,TIME) VALUES(ch[i][0],ch[i][1],ch[i][2])";
InBlock.gif        
string insert_b="INSERT INTO  B_DATA (B_DATA,OFFSET,TIME) VALUES(ch[i][0],ch[i][1],ch[i][2])";
InBlock.gif        
string insert_locom="INSERT INTO  LOCOM_DATA (LOCOM_DATA,OFFSET,TIME) VALUES(ch[i][0],ch[i][1],ch[i][2])";
InBlock.gif        
string insert_s="INSERT INTO  S_DATA (S_DATA,OFFSET,TIME) VALUES(ch[i][0],ch[i][1],ch[i][2])";
InBlock.gif        
string insert_l="INSERT INTO  L_DATA (L_DATA,OFFSET,TIME) VALUES(ch[i][0],ch[i][1],ch[i][2])";
InBlock.gif        
string insert_error="INSERT INTO  ERROR_DATA (ERROR_DATA,OFFSET,TIME) VALUES(ch[i][0],ch[i][1],ch[i][2])";
InBlock.gif
InBlock.gif        
//定义输入数据
InBlock.gif
        private int[]data_mq= new int[1000];
InBlock.gif        
private int[]data_zlj= new int[1000];
InBlock.gif        
private int[]data_return= new int[1000];
InBlock.gif        
private int[]data_rc= new int[1000];
InBlock.gif        
private int[]data_b= new int[1000];
InBlock.gif        
private int[]data_locom= new int[1000];
InBlock.gif        
private int[]data_s= new int[1000];
InBlock.gif        
private int[]data_l= new int[1000];
InBlock.gif        
private int[]data_error= new int[1000];
InBlock.gif        
InBlock.gif        
//定义样本数据(定期更新)
InBlock.gif
        private int[]check_mq= new int[1000];
InBlock.gif        
private int[]check_zlj= new int[1000];
InBlock.gif        
private int[]check_return= new int[1000];
InBlock.gif        
private int[]check_rc= new int[1000];
InBlock.gif        
private int[]check_b= new int[1000];
InBlock.gif        
private int[]check_locom= new int[1000];
InBlock.gif        
private int[]check_s= new int[1000];
InBlock.gif        
private int[]check_l= new int[1000];
InBlock.gif        
private int[]check_error= new int[1000];
InBlock.gif
InBlock.gif        
//进程说明
InBlock.gif
        private Thread mq;
InBlock.gif        
private Thread zlj;
InBlock.gif        
private Thread return_mq;
InBlock.gif        
private Thread rc;
InBlock.gif        
private Thread b;
InBlock.gif        
private Thread locom;
InBlock.gif        
private Thread s;
InBlock.gif        
private Thread error;
InBlock.gif        
private Thread l;
InBlock.gif        
private Thread t;
InBlock.gif
InBlock.gif        
private int x;//数组长度
ExpandedSubBlockEnd.gif
        #endregion

InBlock.gif
InBlock.gif        
//数据库连接
InBlock.gif
        SqlConnection mySqlConnection=new SqlConnection("server=(local);database=GroundDB;uid=sa;pwd=sa");
InBlock.gif        
InBlock.gif        
public Form1()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//
InBlock.gif            
// Windows 窗体设计器支持所必需的
InBlock.gif            
//
InBlock.gif
            currentTime1=System.DateTime.Now;
InBlock.gif
InBlock.gif            InitializeComponent();
InBlock.gif            
InBlock.gif            button2.Enabled
=false;
InBlock.gif            button3.Enabled
=false;
InBlock.gif
InBlock.gif            
//开辟进程
InBlock.gif
            mq=new Thread(new ThreadStart(MQ));
InBlock.gif            zlj
=new Thread(new ThreadStart(ZLJ));
InBlock.gif            return_mq
=new Thread(new ThreadStart(RETURN));
InBlock.gif            rc
=new Thread(new ThreadStart(RC_DATA));
InBlock.gif            b
=new Thread(new ThreadStart(B_DATA));
InBlock.gif            locom
=new Thread (new ThreadStart(LOCOM_DATA));
InBlock.gif            s
=new Thread(new ThreadStart(S_DATA));
InBlock.gif            l
=new Thread (new ThreadStart(L_DATA));
InBlock.gif            error
=new Thread (new ThreadStart(ERROR_DATA));
InBlock.gif            t
=new Thread(new ThreadStart(ProgBar));
InBlock.gif            
//
InBlock.gif            
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
InBlock.gif            
//
ExpandedSubBlockEnd.gif
        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// 
InBlock.gif        
/// 清理所有正在使用的资源。
ExpandedSubBlockEnd.gif        
/// 

InBlock.gif        protected override void Dispose( bool disposing )
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if( disposing )
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if (components != null
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    components.Dispose();
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            
base.Dispose( disposing );
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
Windows 窗体设计器生成的代码#region Windows 窗体设计器生成的代码
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// 
InBlock.gif        
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
InBlock.gif        
/// 此方法的内容。
ExpandedSubBlockEnd.gif        
/// 

InBlock.gif        private void InitializeComponent()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            System.Resources.ResourceManager resources 
= new System.Resources.ResourceManager(typeof(Form1));
InBlock.gif            
this.button1 = new System.Windows.Forms.Button();
InBlock.gif            
this.button2 = new System.Windows.Forms.Button();
InBlock.gif            
this.button3 = new System.Windows.Forms.Button();
InBlock.gif            
this.button4 = new System.Windows.Forms.Button();
InBlock.gif            
this.button5 = new System.Windows.Forms.Button();
InBlock.gif            
this.progressBar1 = new System.Windows.Forms.ProgressBar();
InBlock.gif            
this.label1 = new System.Windows.Forms.Label();
InBlock.gif            
this.button6 = new System.Windows.Forms.Button();
InBlock.gif            
this.SuspendLayout();
InBlock.gif            
// 
InBlock.gif            
// button1
InBlock.gif            
// 
InBlock.gif
            this.button1.Location = new System.Drawing.Point(56112);
InBlock.gif            
this.button1.Name = "button1";
InBlock.gif            
this.button1.TabIndex = 0;
InBlock.gif            
this.button1.Text = "接收数据";
InBlock.gif            
this.button1.Click += new System.EventHandler(this.button1_Click);
InBlock.gif            
// 
InBlock.gif            
// button2
InBlock.gif            
// 
InBlock.gif
            this.button2.Location = new System.Drawing.Point(184112);
InBlock.gif            
this.button2.Name = "button2";
InBlock.gif            
this.button2.TabIndex = 1;
InBlock.gif            
this.button2.Text = "挂起";
InBlock.gif            
this.button2.Click += new System.EventHandler(this.button2_Click);
InBlock.gif            
// 
InBlock.gif            
// button3
InBlock.gif            
// 
InBlock.gif
            this.button3.Location = new System.Drawing.Point(312112);
InBlock.gif            
this.button3.Name = "button3";
InBlock.gif            
this.button3.TabIndex = 2;
InBlock.gif            
this.button3.Text = "恢复";
InBlock.gif            
this.button3.Click += new System.EventHandler(this.button3_Click);
InBlock.gif            
// 
InBlock.gif            
// button4
InBlock.gif            
// 
InBlock.gif
            this.button4.Location = new System.Drawing.Point(432112);
InBlock.gif            
this.button4.Name = "button4";
InBlock.gif            
this.button4.TabIndex = 3;
InBlock.gif            
this.button4.Text = "停止";
InBlock.gif            
this.button4.Click += new System.EventHandler(this.button4_Click);
InBlock.gif            
// 
InBlock.gif            
// button5
InBlock.gif            
// 
InBlock.gif
            this.button5.Location = new System.Drawing.Point(312184);
InBlock.gif            
this.button5.Name = "button5";
InBlock.gif            
this.button5.Size = new System.Drawing.Size(9623);
InBlock.gif            
this.button5.TabIndex = 4;
InBlock.gif            
this.button5.Text = "退出";
InBlock.gif            
this.button5.Click += new System.EventHandler(this.button5_Click);
InBlock.gif            
// 
InBlock.gif            
// progressBar1
InBlock.gif            
// 
InBlock.gif
            this.progressBar1.Location = new System.Drawing.Point(16040);
InBlock.gif            
this.progressBar1.Name = "progressBar1";
InBlock.gif            
this.progressBar1.Size = new System.Drawing.Size(35232);
InBlock.gif            
this.progressBar1.TabIndex = 5;
InBlock.gif            
// 
InBlock.gif            
// label1
InBlock.gif            
// 
InBlock.gif
            this.label1.Location = new System.Drawing.Point(5640);
InBlock.gif            
this.label1.Name = "label1";
InBlock.gif            
this.label1.Size = new System.Drawing.Size(8032);
InBlock.gif            
this.label1.TabIndex = 7;
InBlock.gif            
this.label1.Text = "当前状态:";
InBlock.gif            
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
InBlock.gif            
// 
InBlock.gif            
// button6
InBlock.gif            
// 
InBlock.gif
            this.button6.Location = new System.Drawing.Point(160184);
InBlock.gif            
this.button6.Name = "button6";
InBlock.gif            
this.button6.Size = new System.Drawing.Size(9623);
InBlock.gif            
this.button6.TabIndex = 8;
InBlock.gif            
this.button6.Text = "查看";
InBlock.gif            
this.button6.Click += new System.EventHandler(this.button6_Click);
InBlock.gif            
// 
InBlock.gif            
// Form1
InBlock.gif            
// 
InBlock.gif
            this.AutoScale = false;
InBlock.gif            
this.AutoScaleBaseSize = new System.Drawing.Size(614);
InBlock.gif            
this.AutoScroll = true;
InBlock.gif            
this.ClientSize = new System.Drawing.Size(560266);
InBlock.gif            
this.Controls.Add(this.button6);
InBlock.gif            
this.Controls.Add(this.label1);
InBlock.gif            
this.Controls.Add(this.progressBar1);
InBlock.gif            
this.Controls.Add(this.button5);
InBlock.gif            
this.Controls.Add(this.button4);
InBlock.gif            
this.Controls.Add(this.button3);
InBlock.gif            
this.Controls.Add(this.button2);
InBlock.gif            
this.Controls.Add(this.button1);
InBlock.gif            
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
InBlock.gif            
this.Name = "Form1";
InBlock.gif            
this.Text = "数据接收";
InBlock.gif            
this.Load += new System.EventHandler(this.Form1_Load);
InBlock.gif            
this.ResumeLayout(false);
InBlock.gif
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif        
#endregion

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// 
InBlock.gif        
/// 应用程序的主入口点。
ExpandedSubBlockEnd.gif        
/// 

InBlock.gif        [STAThread]
InBlock.gif        
static void Main() 
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Application.Run(
new Form1());
InBlock.gif            
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void SavePoint(string save)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            SqlCommand mySqlCommand
=mySqlConnection.CreateCommand();
InBlock.gif            mySqlConnection.Open();
InBlock.gif            SqlTransaction mySqlTransaction
=mySqlConnection.BeginTransaction();
InBlock.gif            mySqlCommand.Transaction
=mySqlTransaction;
InBlock.gif            
//保存记录
InBlock.gif
            mySqlTransaction.Save("Save_mq");
InBlock.gif
InBlock.gif            
//记录回滚
InBlock.gif            
//mySqlTransaction.Rollback(Savepoint);
ExpandedSubBlockEnd.gif
        }

InBlock.gif
InBlock.gif        
private void timer()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif
//            long a1=DateTime.Now.Ticks;//millsecond 单位
InBlock.gif
//            //System.DateTime b=System.DateTime.Now;
InBlock.gif
//
InBlock.gif
//            int []In=new int [1000];//接收数据
ExpandedSubBlockStart.gifContractedSubBlock.gif
/**/////
InBlock.gif//            do
InBlock.gif
//            {
InBlock.gif
//                check=In;
InBlock.gif
//            }
InBlock.gif
//            while ((a2-a1)/(10*60*1000))==0);
ExpandedSubBlockEnd.gif
        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
threading  !!!???#region threading  !!!???
InBlock.gif        
//进程函数定义
InBlock.gif
        private void ProgBar()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
do
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{    
InBlock.gif                Thread.Sleep(
500);
InBlock.gif                
if (progressBar1.Value >= 100 )
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{    
InBlock.gif                    progressBar1.Value 
= 0;
ExpandedSubBlockEnd.gif                }

InBlock.gif                progressBar1.Value 
+= 5;
ExpandedSubBlockEnd.gif            }
while (true);
InBlock.gif            SavePoint(
"save");
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void MQ()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
int[,] check=new int[x,3];
InBlock.gif            
int i=0;
InBlock.gif            
int j=0;
InBlock.gif            currentTime
=System.DateTime.Now;
InBlock.gif            
int Mills=currentTime.Millisecond;        
InBlock.gif            
for(i=0;i<=x;)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{            
InBlock.gif                
if((data_mq[i]!=check_mq[i])&&(j<x))
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                        check[j,
2]=Mills;
InBlock.gif                        check[j,
1]=data_mq[i];
InBlock.gif                        check[j,
0]=i;
InBlock.gif                        j
++;
InBlock.gif                        i
++;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            DataConn(check,insert_mq);
ExpandedSubBlockEnd.gif        }

InBlock.gif        
InBlock.gif        
private void ZLJ()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
InBlock.gif            
int[,] check=new int[x,3];
InBlock.gif            
int i=0;
InBlock.gif            
int j=0;
InBlock.gif            currentTime
=System.DateTime.Now;
InBlock.gif            
int Mills=currentTime.Millisecond;
InBlock.gif            
for(i=0;i<=x;)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{            
InBlock.gif                
if((data_mq[i]!=check_zlj[i])&&(j<x))
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    check[j,
2]=Mills;
InBlock.gif                    check[j,
1]=data_zlj[i];
InBlock.gif                    check[j,
0]=i;                    
InBlock.gif                    j
++;
InBlock.gif                    i
++;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            DataConn(check,insert_zlj);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void RETURN()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
int[,] check=new int[x,3];
InBlock.gif            
int i=0;
InBlock.gif            
int j=0;
InBlock.gif            currentTime
=System.DateTime.Now;
InBlock.gif            
int Mills=currentTime.Millisecond;        
InBlock.gif            
for(i=0;i<=x;)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{            
InBlock.gif                
if((data_mq[i]!=check_return[i])&&(j<x))
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    check[j,
2]=Mills;
InBlock.gif                    check[j,
1]=data_return[i];
InBlock.gif                    check[j,
0]=i;                
InBlock.gif                    j
++;
InBlock.gif                    i
++;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            DataConn(check,insert_return);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void RC_DATA()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
int[,] check=new int[x,3];
InBlock.gif            
int i=0;
InBlock.gif            
int j=0;
InBlock.gif            currentTime
=System.DateTime.Now;
InBlock.gif            
int Mills=currentTime.Millisecond;    
InBlock.gif            
for(i=0;i<=x;)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{            
InBlock.gif                
if((data_mq[i]!=check_rc[i])&&(j<x))
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    check[j,
2]=Mills;
InBlock.gif                    check[j,
1]=data_rc[i];
InBlock.gif                    check[j,
0]=i;    
InBlock.gif                    j
++;
InBlock.gif                    i
++;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            DataConn(check,insert_rc);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void B_DATA()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
int[,] check=new int[x,3];
InBlock.gif            
int i=0;
InBlock.gif            
int j=0;
InBlock.gif            currentTime
=System.DateTime.Now;
InBlock.gif            
int Mills=currentTime.Millisecond;    
InBlock.gif            
for(i=0;i<=x;)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{            
InBlock.gif                
if((data_mq[i]!=check_b[i])&&(j<x))
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    check[j,
2]=Mills;
InBlock.gif                    check[j,
1]=data_b[i];
InBlock.gif                    check[j,
0]=i;                
InBlock.gif                    j
++;
InBlock.gif                    i
++;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            DataConn(check,insert_b);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void LOCOM_DATA()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
int[,] check=new int[x,3];
InBlock.gif            
int i=0;
InBlock.gif            
int j=0;
InBlock.gif            currentTime
=System.DateTime.Now;
InBlock.gif            
int Mills=currentTime.Millisecond;    
InBlock.gif            
for(i=0;i<=x;)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{            
InBlock.gif                
if((data_mq[i]!=check_locom[i])&&(j<x))
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    check[j,
2]=Mills;
InBlock.gif                    check[j,
1]=data_locom[i];
InBlock.gif                    check[j,
0]=i;
InBlock.gif                    j
++;
InBlock.gif                    i
++;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            DataConn(check,insert_locom);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void S_DATA()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
int[,] check=new int[x,3];
InBlock.gif            
int i=0;
InBlock.gif            
int j=0;
InBlock.gif            currentTime
=System.DateTime.Now;
InBlock.gif            
int Mills=currentTime.Millisecond;        
InBlock.gif            
for(i=0;i<=x;)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{            
InBlock.gif                
if((data_mq[i]!=check_s[i])&&(j<x))
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    check[j,
2]=Mills;
InBlock.gif                    check[j,
1]=data_s[i];
InBlock.gif                    check[j,
0]=i;                    
InBlock.gif                    j
++;
InBlock.gif                    i
++;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            DataConn(check,insert_s);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void L_DATA()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
int[,] check=new int[x,3];
InBlock.gif            
int i=0;
InBlock.gif            
int j=0;
InBlock.gif            currentTime
=System.DateTime.Now;
InBlock.gif            
int Mills=currentTime.Millisecond;    
InBlock.gif            
for(i=0;i<=x;)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{            
InBlock.gif                
if((data_mq[i]!=check_l[i])&&(j<x))
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    check[j,
2]=Mills;
InBlock.gif                    check[j,
1]=data_l[i];
InBlock.gif                    check[j,
0]=i;
InBlock.gif                    
InBlock.gif                    j
++;
InBlock.gif                    i
++;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            DataConn(check,insert_l);
ExpandedSubBlockEnd.gif        }

InBlock.gif        
private void ERROR_DATA()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
int[,] check=new int[x,3];
InBlock.gif            
int i=0;
InBlock.gif            
int j=0;
InBlock.gif            currentTime
=System.DateTime.Now;
InBlock.gif            
int Mills=currentTime.Millisecond;    
InBlock.gif            
for(i=0;i<=x;)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{            
InBlock.gif                
if((data_mq[i]!=check_error[i])&&(j<x))
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    check[j,
2]=Mills;
InBlock.gif                    check[j,
1]=data_error[i];
InBlock.gif                    check[j,
0]=i;
InBlock.gif                    DataConn(check,insert_error);
InBlock.gif                    j
++;
InBlock.gif                    i
++;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif        
#endregion
 
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
Conn#region Conn
InBlock.gif        
private void DataConn(int[,] a,string insert)//check 数组 ,the name of database ,insert
ExpandedSubBlockStart.gifContractedSubBlock.gif
        dot.gif{//数据存储
InBlock.gif
            int[,] ch=new int [x,3];
InBlock.gif            ch
=a;
InBlock.gif            SqlCommand mySqlCommand
=mySqlConnection.CreateCommand();    
InBlock.gif            SqlDataAdapter mySqlDataAdapter
=new SqlDataAdapter();
InBlock.gif            
for(int i=0;i<x;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                mySqlCommand.CommandText
=insert;
InBlock.gif                
//计算所插入的数组数量
InBlock.gif                
//int nomberOfRows=mySqlCommand.ExecuteNonQuery();
ExpandedSubBlockEnd.gif
            }

InBlock.gif            mySqlCommand.Connection.Close();
ExpandedSubBlockEnd.gif        }

InBlock.gif        
ExpandedSubBlockEnd.gif        
#endregion

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
winform#region winform
InBlock.gif        
private void button1_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            currentTime0
=System.DateTime.Now;//取时间样本
InBlock.gif            
//进程开始
InBlock.gif
            t.Start();
InBlock.gif            zlj.Start();
InBlock.gif            return_mq.Start();
InBlock.gif            rc.Start();
InBlock.gif            b.Start();
InBlock.gif            locom.Start();
InBlock.gif            s.Start();
InBlock.gif            l.Start();
InBlock.gif            error.Start();
InBlock.gif            mq.Start();
InBlock.gif
InBlock.gif            button1.Enabled
=false;
InBlock.gif            button2.Enabled
=true;
InBlock.gif            button3.Enabled
=false;
InBlock.gif
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void button2_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{    
InBlock.gif            
//进程挂起
InBlock.gif
            mq.Suspend();
InBlock.gif            t.Suspend();
InBlock.gif            zlj.Suspend();
InBlock.gif            return_mq.Suspend();
InBlock.gif            rc.Suspend();
InBlock.gif            b.Suspend();
InBlock.gif            locom.Suspend();
InBlock.gif            s.Suspend();
InBlock.gif            l.Suspend();
InBlock.gif            error.Suspend();
InBlock.gif
InBlock.gif            button2.Enabled
=false;
InBlock.gif            button3.Enabled
=true;
InBlock.gif            button4.Enabled
=false;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void button3_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//进程恢复
InBlock.gif
            mq.Resume();
InBlock.gif            t.Resume();
InBlock.gif            zlj.Resume();
InBlock.gif            return_mq.Resume();
InBlock.gif            rc.Resume();
InBlock.gif            b.Resume();
InBlock.gif            locom.Resume();
InBlock.gif            s.Resume();
InBlock.gif            l.Resume();
InBlock.gif            error.Resume();
InBlock.gif
InBlock.gif            button2.Enabled
=true;
InBlock.gif            button3.Enabled
=false;
InBlock.gif            button4.Enabled
=true;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void button4_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//进程退出
InBlock.gif
            t.Abort();
InBlock.gif            mq.Abort();
InBlock.gif            zlj.Abort();
InBlock.gif            return_mq.Abort();
InBlock.gif            rc.Abort();
InBlock.gif            b.Abort();
InBlock.gif            locom.Abort();
InBlock.gif            s.Abort();
InBlock.gif            l.Abort();
InBlock.gif            error.Abort();
InBlock.gif
InBlock.gif            button2.Enabled
=false;
InBlock.gif            button3.Enabled
=false;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void button6_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//打开form2
InBlock.gif
            Form2 form2=new Form2();
InBlock.gif            form2.ShowDialog();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void button5_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//关闭form
InBlock.gif
            this.Close();
ExpandedSubBlockEnd.gif        }

InBlock.gif        
private void timer1_Tick(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void Form1_Load(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif        
#endregion
 
ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif

转载于:https://www.cnblogs.com/TZ-1983/archive/2005/09/01/227979.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值