代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
CSharp
】
一个winform的基于TCP的服务端的GPS平台的网关。利用
作者:
Dezai.CN
/ 发布于
2012/2/8
/
707
GPS平台
<div> <div class="container"> <div class="line number1 index0 alt2">"csharp keyword">using "csharp plain">System; </div> <div class="line number2 index1 alt1">"csharp keyword">using "csharp plain">System.Collections; </div> <div class="line number3 index2 alt2">"csharp keyword">using "csharp plain">System.Collections.Specialized; </div> <div class="line number4 index3 alt1">"csharp keyword">using "csharp plain">System.Text; </div> <div class="line number5 index4 alt2">"csharp keyword">using "csharp plain">System.Threading; </div> <div class="line number6 index5 alt1">"csharp keyword">using "csharp plain">System.Net.Sockets; </div> <div class="line number7 index6 alt2">"csharp keyword">using "csharp plain">System.Net; </div> <div class="line number8 index7 alt1">"csharp keyword">using "csharp plain">System.Runtime.Serialization; </div> <div class="line number9 index8 alt2">"csharp keyword">using "csharp plain">System.Runtime.Serialization.Formatters.Binary; </div> <div class="line number10 index9 alt1">"csharp keyword">using "csharp plain">System.IO; </div> <div class="line number11 index10 alt2">"csharp keyword">using "csharp plain">System.Data; </div> <div class="line number12 index11 alt1">"csharp keyword">using "csharp plain">System.Windows.Forms; </div> <div class="line number13 index12 alt2">"csharp keyword">using "csharp plain">System.Configuration; </div> <div class="line number14 index13 alt1">"csharp spaces"> </div> <div class="line number15 index14 alt2">"csharp keyword">namespace "csharp plain">WSGPSGateway </div> <div class="line number16 index15 alt1">"csharp plain">{ </div> <div class="line number17 index16 alt2">"csharp spaces"> "csharp keyword">public "csharp keyword">partial "csharp keyword">class "csharp plain">TcpServer : Form </div> <div class="line number18 index17 alt1">"csharp spaces"> "csharp plain">{ </div> <div class="line number19 index18 alt2">"csharp spaces"> "csharp keyword">public "csharp plain">TcpServer() </div> <div class="line number20 index19 alt1">"csharp spaces"> "csharp plain">{ </div> <div class="line number21 index20 alt2">"csharp spaces"> "csharp plain">InitializeComponent(); </div> <div class="line number22 index21 alt1">"csharp spaces"> "csharp plain">} </div> <div class="line number23 index22 alt2">"csharp spaces"> </div> <div class="line number24 index23 alt1">"csharp spaces"> "csharp preprocessor">#region 自定义字段 </div> <div class="line number25 index24 alt2">"csharp spaces"> </div> <div class="line number26 index25 alt1">"csharp spaces"> "csharp color1">/// <summary> </div> <div class="line number27 index26 alt2">"csharp spaces"> "csharp color1">/// 监听控件开启状态 </div> <div class="line number28 index27 alt1">"csharp spaces"> "csharp color1">/// </summary> </div> <div class="line number29 index28 alt2">"csharp spaces"> "csharp keyword">private "csharp keyword">bool "csharp plain">State = "csharp keyword">true"csharp plain">; </div> <div class="line number30 index29 alt1">"csharp spaces"> </div> <div class="line number31 index30 alt2">"csharp spaces"> "csharp color1">/// <summary> </div> <div class="line number32 index31 alt1">"csharp spaces"> "csharp color1">/// 声明一个线程实例 </div> <div class="line number33 index32 alt2">"csharp spaces"> "csharp color1">/// </summary> </div> <div class="line number34 index33 alt1">"csharp spaces"> "csharp keyword">private "csharp plain">Thread mythread; </div> <div class="line number35 index34 alt2">"csharp spaces"> </div> <div class="line number36 index35 alt1">"csharp spaces"> "csharp color1">/// <summary> </div> <div class="line number37 index36 alt2">"csharp spaces"> "csharp color1">/// 服务器端Ip </div> <div class="line number38 index37 alt1">"csharp spaces"> "csharp color1">/// </summary> </div> <div class="line number39 index38 alt2">"csharp spaces"> "csharp keyword">private "csharp keyword">int "csharp plain">_port = Convert.ToInt32(ConfigurationManager.AppSettings["csharp string">"Port""csharp plain">]); </div> <div class="line number40 index39 alt1">"csharp spaces"> </div> <div class="line number41 index40 alt2">"csharp spaces"> "csharp color1">/// <summary> </div> <div class="line number42 index41 alt1">"csharp spaces"> "csharp color1">/// 判断离线时间差设置 </div> <div class="line number43 index42 alt2">"csharp spaces"> "csharp color1">/// </summary> </div> <div class="line number44 index43 alt1">"csharp spaces"> "csharp keyword">private "csharp keyword">string "csharp plain">_spandate = ConfigurationManager.AppSettings["csharp string">"Spandates""csharp plain">]; </div> <div class="line number45 index44 alt2">"csharp spaces"> </div> <div class="line number46 index45 alt1">"csharp spaces"> "csharp color1">/// <summary> </div> <div class="line number47 index46 alt2">"csharp spaces"> "csharp color1">/// 保存客户端所有回话的哈希表 </div> <div class="line number48 index47 alt1">"csharp spaces"> "csharp color1">/// </summary> </div> <div class="line number49 index48 alt2">"csharp spaces"> "csharp keyword">private "csharp plain">Hashtable _transmit_tb = "csharp keyword">new "csharp plain">Hashtable(); </div> <div class="line number50 index49 alt1">"csharp spaces"> </div> <div class="line number51 index50 alt2">"csharp spaces"> "csharp color1">/// <summary> </div> <div class="line number52 index51 alt1">"csharp spaces"> "csharp color1">/// 用于接受消息的线程 </div> <div class="line number53 index52 alt2">"csharp spaces"> "csharp color1">/// </summary> </div> <div class="line number54 index53 alt1">"csharp spaces"> "csharp keyword">private "csharp plain">Thread _receviccethread = "csharp keyword">null"csharp plain">; </div> <div class="line number55 index54 alt2">"csharp spaces"> </div> <div class="line number56 index55 alt1">"csharp spaces"> "csharp keyword">public "csharp keyword">struct "csharp plain">TCPParameter </div> <div class="line number57 index56 alt2">"csharp spaces"> "csharp plain">{ </div> <div class="line number58 index57 alt1">"csharp spaces"> "csharp keyword">public "csharp keyword">string "csharp plain">Package; </div> <div class="line number59 index58 alt2">"csharp spaces"> "csharp keyword">public "csharp keyword">string "csharp plain">IpAddress; </div> <div class="line number60 index59 alt1">"csharp spaces"> "csharp plain">} </div> <div class="line number61 index60 alt2">"csharp spaces"> </div> <div class="line number62 index61 alt1">"csharp spaces"> "csharp preprocessor">#endregion </div> <div class="line number63 index62 alt2">"csharp spaces"> </div> <div class="line number64 index63 alt1">"csharp spaces"> "csharp preprocessor">#region 监听代码块 </div> <div class="line number65 index64 alt2">"csharp spaces"> </div> <div class="line number66 index65 alt1">"csharp spaces"> "csharp comments">//窗体运行 </div> <div class="line number67 index66 alt2">"csharp spaces"> "csharp keyword">private "csharp keyword">void "csharp plain">TcpServer_Load("csharp keyword">object "csharp plain">sender, EventArgs e) </div> <div class="line number68 index67 alt1">"csharp spaces"> "csharp plain">{ </div> <div class="line number69 index68 alt2">"csharp spaces"> "csharp keyword">this"csharp plain">.Hide(); </div> <div class="line number70 index69 alt1">"csharp spaces"> "csharp plain">Form.CheckForIllegalCrossThreadCalls = "csharp keyword">false"csharp plain">; </div> <div class="line number71 index70 alt2">"csharp spaces"> "csharp keyword">try</div> <div class="line number72 index71 alt1">"csharp spaces"> "csharp plain">{ </div> <div class="line number73 index72 alt2">"csharp spaces"> "csharp plain">InitializeComponent(); </div> <div class="line number74 index73 alt1">"csharp spaces"> "csharp plain">mythread = "csharp keyword">new "csharp plain">Thread(Listen); </div> <div class="line number75 index74 alt2">"csharp spaces"> "csharp plain">mythread.Start(); </div> <div class="line number76 index75 alt1">"csharp spaces"> "csharp plain">} </div> <div class="line number77 index76 alt2">"csharp spaces"> "csharp keyword">catch "csharp plain">(Exception ex) </div> <div class="line number78 index77 alt1">"csharp spaces"> "csharp plain">{ </div> <div class="line number79 index78 alt2">"csharp spaces"> "csharp plain">DAL.Log.Write(DateTime.Now + ex.ToString() + "csharp string">"\r\n""csharp plain">); </div> <div class="line number80 index79 alt1">"csharp spaces"> "csharp plain">} </div> <div class="line number81 index80 alt2">"csharp spaces"> "csharp plain">} </div> <div class="line number82 index81 alt1">"csharp spaces"> </div> <div class="line number83 index82 alt2">"csharp spaces"> "csharp keyword">private "csharp keyword">object "csharp plain">threadlock = "csharp keyword">new "csharp keyword">object"csharp plain">(); </div> <div class="line number84 index83 alt1">"csharp spaces"> </div> <div class="line number85 index84 alt2">"csharp spaces"> "csharp comments">//启动监听 </div> <div class="line number86 index85 alt1">"csharp spaces"> "csharp keyword">private "csharp keyword">void "csharp plain">BtnStart_Click("csharp keyword">object "csharp plain">sender, EventArgs e) </div> <div class="line number87 index86 alt2">"csharp spaces"> "csharp plain">{ </div> <div class="line number88 index87 alt1">"csharp spaces"> "csharp comments">//锁定区域同时进行数据处理 </div> <div class="line number89 index88 alt2">"csharp spaces"> "csharp plain">Monitor.Enter(threadlock); </div> <div class="line number90 index89 alt1">"csharp spaces"> "csharp keyword">try</div> <div class="line number91 index90 alt2">"csharp spaces"> "csharp plain">{ </div> <div class="line number92 index91 alt1">"csharp spaces"> "csharp comments">//启动线程 </div> <div class="line number93 index92 alt2">"csharp spaces"> "csharp plain">ThreadStart thsrt = "csharp keyword">new "csharp plain">ThreadStart(Listen); </div> <div class="line number94 index93 alt1">"csharp spaces"> "csharp comments">//10个线程全部执行统一的方法 </div> <div class="line number95 index94 alt2">"csharp spaces"> "csharp plain">Thread[] threads = "csharp keyword">new "csharp plain">Thread[10]; </div> <div class="line number96 index95 alt1">"csharp spaces"> </div> <div class="line number97 index96 alt2">"csharp spaces"> "csharp keyword">if "csharp plain">(State) "csharp comments">//如果状态是true,表示可以开启 </div> <div class="line number98 index97 alt1">"csharp spaces"> "csharp plain">{ </div> <div class="line number99 index98 alt2">"csharp spaces"> "csharp comments">//循环10个线程 </div> <div class="line number100 index99 alt1">"csharp spaces"> "csharp keyword">for "csharp plain">("csharp keyword">int "csharp plain">i = 0; i < 10; i++) </div> <div class="line number101 index100 alt2">"csharp spaces"> "csharp plain">{ </div> <div class="line number102 index101 alt1">"csharp spaces"> "csharp plain">threads[i] = "csharp keyword">new "csharp plain">Thread(thsrt); </div> <div class="line number103 index102 alt2">"csharp spaces"> "csharp comments">//设置线程为后台后台线程 ,也叫守护线程 </div> <div class="line number104 index103 alt1">"csharp spaces"> "csharp plain">threads[i].IsBackground = "csharp keyword">true"csharp plain">; </div> <div class="line number105 index104 alt2">"csharp spaces"> "csharp plain">} </div> <div class="line number106 index105 alt1">"csharp spaces"> "csharp comments">//循环遍历所有的10个线程 </div> <div class="line number107 index106 alt2">"csharp spaces"> "csharp keyword">foreach "csharp plain">(Thread th "csharp keyword">in "csharp plain">threads) </div> <div class="line number108 index107 alt1">"csharp spaces"> "csharp plain">{ </div> <div class="line number109 index108 alt2">"csharp spaces"> "csharp comments">//开启线程 </div> <div class="line number110 index109 alt1">"csharp spaces"> "csharp plain">th.Start(); </div> <div class="line number111 index110 alt2">"csharp spaces"> "csharp plain">} </div> <div class="line number112 index111 alt1">"csharp spaces"> "csharp comments">//将状态改为false </div> <div class="line number113 index112 alt2">"csharp spaces"> "csharp plain">State = "csharp keyword">false"csharp plain">; </div> <div class="line number114 index113 alt1">"csharp spaces"> "csharp keyword">this"csharp plain">.Messagetxt.Text = "csharp string">"服务已启动,正在侦听...""csharp plain">; </div> <div class="line number115 index114 alt2">"csharp spaces"> "csharp plain">} </div> <div class="line number116 index115 alt1">"csharp spaces"> "csharp keyword">else</div> <div class="line number117 index116 alt2">"csharp spaces"> "csharp plain">{ </div> <div class="line number118 index117 alt1">"csharp spaces"> "csharp comments">//中断线程 </div> <div class="line number119 index118 alt2">"csharp spaces"> "csharp plain">mythread.Interrupt(); </div> <div class="line number120 index119 alt1">"csharp spaces"> "csharp comments">//终止线程 </div> <div class="line number121 index120 alt2">"csharp spaces"> "csharp plain">mythread.Abort(); </div> <div class="line number122 index121 alt1">"csharp spaces"> "csharp plain">State = "csharp keyword">true"csharp plain">; </div> <div class="line number123 index122 alt2">"csharp spaces"> "csharp keyword">this"csharp plain">.Messagetxt.Text = "csharp string">"服务已关闭,等待开启...""csharp plain">; </div> <div class="line number124 index123 alt1">"csharp spaces"> "csharp plain">} </div> <div class="line number125 index124 alt2">"csharp spaces"> "csharp plain">} </div> <div class="line number126 index125 alt1">"csharp spaces"> "csharp keyword">catch "csharp plain">(Exception ex) </div> <div class="line number127 index126 alt2">"csharp spaces"> "csharp plain">{ </div> <div class="line number128 index127 alt1">"csharp spaces"> "csharp plain">DAL.Log.Write(DateTime.Now + ex.ToString() + "csharp string">"\r\n""csharp plain">); </div> <div class="line number129 index128 alt2">"csharp spaces"> "csharp plain">} </div> <div class="line number130 index129 alt1">"csharp spaces"> "csharp keyword">finally</div> <div class="line number131 index130 alt2">"csharp spaces"> "csharp plain">{ </div> <div class="line number132 index131 alt1">"csharp spaces"> "csharp comments">//退出对于线程的锁定 </div> <div class="line number133 index132 alt2">"csharp spaces"> "csharp plain">Monitor.Exit(threadlock); </div> <div class="line number134 index133 alt1">"csharp spaces"> "csharp plain">} </div> <div class="line number135 index134 alt2">"csharp spaces"> "csharp plain">} </div> <div class="line number136 index135 alt1">"csharp spaces"> </div> <div class="line number137 index136 alt2">"csharp spaces"> "csharp comments">//启动监听,轮询监听客户机请求并将客户端套接字存入转发表 </div> <div class="line number138 index137 alt1">"csharp spaces"> "csharp keyword">private "csharp keyword">void "csharp plain">Listen() </div> <div class="line number139 index138 alt2">"csharp spaces"> "csharp plain">{ </div> <div class="line number140 index139 alt1">"csharp spaces"> "csharp keyword">try</div> <div class="line number141 index140 alt2">"csharp spaces"> "csharp plain">{ </div> <div class="line number142 index141 alt1">"csharp spaces"> "csharp plain">IPAddress _ip = IPAddress.Any; </div> <div class="line number143 index142 alt2">"csharp spaces"> "csharp plain">Socket newsoc = "csharp keyword">new "csharp plain">Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); </div> <div class="line number144 index143 alt1">"csharp spaces"> "csharp plain">newsoc.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, "csharp keyword">true"csharp plain">); </div> <div class="line number145 index144 alt2">"csharp spaces"> "csharp plain">IPEndPoint locaEp = "csharp keyword">new "csharp plain">IPEndPoint(IPAddress.Any, _port);"csharp comments">//建立连接 </div> <div class="line number146 index145 alt1">"csharp spaces"> "csharp plain">newsoc.Bind(locaEp); </div> <div class="line number147 index146 alt2">"csharp spaces"> "csharp plain">newsoc.Listen(100); </div> <div class="line number148 index147 alt1">"csharp spaces"> "csharp plain">newsoc.BeginAccept("csharp keyword">new "csharp plain">AsyncCallback(onCall), newsoc);"csharp comments">//继续接受其他客户端的连接 </div> <div class="line number149 index148 alt2">"csharp spaces"> "csharp plain">} </div> <div class="line number150 index149 alt1">"csharp spaces"> "csharp keyword">catch "csharp plain">(Exception ex) </div> <div class="line number151 index150 alt2">"csharp spaces"> "csharp plain">{ </div> <div class="line number152 index151 alt1">"csharp spaces"> "csharp plain">DAL.Log.Write(DateTime.Now.ToString() + ex.ToString() + "csharp string">"\r\n""csharp plain">); </div> <div class="line number153 index152 alt2">"csharp spaces"> "csharp plain">} </div> <div class="line number154 index153 alt1">"csharp spaces"> "csharp plain">} </div> <div class="line number155 index154 alt2">"csharp spaces"> </div> <div class="line number156 index155 alt1">"csharp spaces"> "csharp comments">//监听回调 </div> <div class="line number157 index156 alt2">"csharp spaces"> "csharp keyword">private "csharp keyword">void "csharp plain">onCall(IAsyncResult ar) </div> <div class="line number158 index157 alt1">"csharp spaces"> "csharp plain">{ </div> <div class="line number159 index158 alt2">"csharp spaces"> "csharp keyword">try</div> <div class="line number160 index159 alt1">"csharp spaces"> "csharp plain">{ </div> <div class="line number161 index160 alt2">"csharp spaces"> "csharp plain">Socket serverSoc = (Socket)ar.AsyncState; </div> <div class="line number162 index161 alt1">"csharp spaces"> "csharp plain">Socket clent = serverSoc.EndAccept(ar); </div> <div class="line number163 index162 alt2">"csharp spaces"> "csharp keyword">byte"csharp plain">[] comes = "csharp keyword">new "csharp keyword">byte"csharp plain">[1024]; </div> <div class="line number164 index163 alt1">"csharp spaces"> "csharp plain">EndPoint enp = clent.RemoteEndPoint; </div> <div class="line number165 index164 alt2">"csharp spaces"> "csharp plain">serverSoc.BeginAccept("csharp keyword">new "csharp plain">AsyncCallback(onCall), serverSoc); </div> <div class="line number166 index165 alt1">"csharp spaces"> "csharp keyword">while "csharp plain">("csharp keyword">true"csharp plain">) </div> <div class="line number167 index166 alt2">"csharp spaces"> "csharp plain">{ </div> <div class="line number168 index167 alt1">"csharp spaces"> "csharp keyword">int "csharp plain">re = clent.Receive(comes); </div> <div class="line number169 index168 alt2">"csharp spaces"> "csharp plain">clent.Send(Encoding.ASCII.GetBytes("csharp string">"ok!""csharp plain">)); </div> <div class="line number170 index169 alt1">"csharp spaces"> "csharp plain">TCPParameter parm = "csharp keyword">new "csharp plain">TCPParameter(); </div> <div class="line number171 index170 alt2">"csharp spaces"> "csharp plain">parm.Package = Encoding.UTF8.GetString(comes, 0, re); </div> <div class="line number172 index171 alt1">"csharp spaces"> "csharp plain">parm.IpAddress = clent.RemoteEndPoint.ToString(); </div> <div class="line number173 index172 alt2">"csharp spaces"> </div> <div class="line number174 index173 alt1">"csharp spaces"> "csharp keyword">if "csharp plain">(parm.Package.Length == 0) </div> <div class="line number175 index174 alt2">"csharp spaces"> "csharp plain">{ </div> <div class="line number176 index175 alt1">"csharp spaces"> "csharp plain">_receviccethread.Interrupt(); </div> <div class="line number177 index176 alt2">"csharp spaces"> "csharp plain">_receviccethread.Abort(); </div> <div class="line number178 index177 alt1">"csharp spaces"> "csharp plain">} </div> <div class="line number179 index178 alt2">"csharp spaces"> "csharp plain">Receive(parm.Package, parm.IpAddress); </div> <div class="line number180 index179 alt1">"csharp spaces"> "csharp plain">} </div> <div class="line number181 index180 alt2">"csharp spaces"> "csharp plain">} </div> <div class="line number182 index181 alt1">"csharp spaces"> "csharp keyword">catch "csharp plain">(Exception ex) </div> <div class="line number183 index182 alt2">"csharp spaces"> "csharp plain">{ </div> <div class="line number184 index183 alt1">"csharp spaces"> "csharp plain">DAL.Log.Write(DateTime.Now.ToString() + ex.ToString() + "csharp string">"\r\n""csharp plain">); </div> <div class="line number185 index184 alt2">"csharp spaces"> "csharp plain">} </div> <div class="line number186 index185 alt1">"csharp spaces"> "csharp plain">} </div> <div class="line number187 index186 alt2">"csharp spaces"> </div> <div class="line number188 index187 alt1">"csharp spaces"> "csharp comments">//处理解析数据 </div> <div class="line number189 index188 alt2">"csharp spaces"> "csharp keyword">private "csharp keyword">void "csharp plain">Receive("csharp keyword">string "csharp plain">msg, "csharp keyword">string "csharp plain">ip) </div> <div class="line number190 index189 alt1">"csharp spaces"> "csharp plain">{ </div> <div class="line number191 index190 alt2">"csharp spaces"> "csharp plain">ArrayList MessageRet = BLL.ClientLib.AdapterFactory.Prepare(msg,ip);"csharp comments">//转入适配器并返回解析后数据 </div> <div class="line number192 index191 alt1">"csharp spaces"> </div> <div class="line number193 index192 alt2">"csharp spaces"> "csharp keyword">if "csharp plain">(MessageRet.Count != 0) </div> <div class="line number194 index193 alt1">"csharp spaces"> "csharp plain">{ </div> <div class="line number195 index194 alt2">"csharp spaces"> "csharp plain">BLL.ClientLib.ResloveBuffer resbuf = "csharp keyword">new "csharp plain">BLL.ClientLib.ResloveBuffer(); </div> <div class="line number196 index195 alt1">"csharp spaces"> "csharp plain">resbuf.Prepare(MessageRet[0].ToString(), ip);"csharp comments">//将数据二次解析后保存数据库 </div> <div class="line number197 index196 alt2">"csharp spaces"> "csharp plain">} </div> <div class="line number198 index197 alt1">"csharp spaces"> "csharp plain">} </div> <div class="line number199 index198 alt2">"csharp spaces"> </div> <div class="line number200 index199 alt1">"csharp spaces"> "csharp preprocessor">#endregion </div> <div class="line number201 index200 alt2">"csharp spaces"> </div> <div class="line number202 index201 alt1">"csharp spaces"> "csharp preprocessor">#region 关闭与退出 </div> <div class="line number203 index202 alt2">"csharp spaces"> </div> <div class="line number204 index203 alt1">"csharp spaces"> "csharp comments">//窗体关闭 </div> <div class="line number205 index204 alt2">"csharp spaces"> "csharp keyword">private "csharp keyword">void "csharp plain">TcpServer_FormClosing("csharp keyword">object "csharp plain">sender, FormClosingEventArgs e) </div> <div class="line number206 index205 alt1">"csharp spaces"> "csharp plain">{ </div> <div class="line number207 index206 alt2">"csharp spaces"> "csharp keyword">try</div> <div class="line number208 index207 alt1">"csharp spaces"> "csharp plain">{ </div> <div class="line number209 index208 alt2">"csharp spaces"> "csharp keyword">if "csharp plain">(mythread != "csharp keyword">null"csharp plain">) </div> <div class="line number210 index209 alt1">"csharp spaces"> "csharp plain">{ </div> <div class="line number211 index210 alt2">"csharp spaces"> "csharp plain">mythread.Interrupt(); </div> <div class="line number212 index211 alt1">"csharp spaces"> "csharp plain">mythread.Abort(); </div> <div class="line number213 index212 alt2">"csharp spaces"> "csharp plain">GC.Collect(); </div> <div class="line number214 index213 alt1">"csharp spaces"> "csharp plain">} </div> <div class="line number215 index214 alt2">"csharp spaces"> "csharp keyword">else</div> <div class="line number216 index215 alt1">"csharp spaces"> "csharp plain">{ </div> <div class="line number217 index216 alt2">"csharp spaces"> "csharp keyword">this"csharp plain">.Messagetxt.Text = "csharp string">"系统正在运行中...""csharp plain">; </div> <div class="line number218 index217 alt1">"csharp spaces"> "csharp plain">} </div> <div class="line number219 index218 alt2">"csharp spaces"> "csharp plain">} </div> <div class="line number220 index219 alt1">"csharp spaces"> "csharp keyword">catch "csharp plain">(Exception ex) </div> <div class="line number221 index220 alt2">"csharp spaces"> "csharp plain">{ </div> <div class="line number222 index221 alt1">"csharp spaces"> "csharp plain">DAL.Log.Write(DateTime.Now + ex.ToString() + "csharp string">"\r\n""csharp plain">); </div> <div class="line number223 index222 alt2">"csharp spaces"> "csharp plain">} </div> <div class="line number224 index223 alt1">"csharp spaces"> "csharp plain">} </div> <div class="line number225 index224 alt2">"csharp spaces"> </div> <div class="line number226 index225 alt1">"csharp spaces"> "csharp preprocessor">#endregion </div> <div class="line number227 index226 alt2">"csharp spaces"> </div> <div class="line number228 index227 alt1">"csharp spaces"> "csharp preprocessor">#region 执行定时任务 </div> <div class="line number229 index228 alt2">"csharp spaces"> </div> <div class="line number230 index229 alt1">"csharp spaces"> "csharp comments">//执行定时查询设备状态 </div> <div class="line number231 index230 alt2">"csharp spaces"> "csharp keyword">private "csharp keyword">void "csharp plain">timers_Tick("csharp keyword">object "csharp plain">sender, EventArgs e) </div> <div class="line number232 index231 alt1">"csharp spaces"> "csharp plain">{ </div> <div class="line number233 index232 alt2">"csharp spaces"> "csharp keyword">try</div> <div class="line number234 index233 alt1">"csharp spaces"> "csharp plain">{ </div> <div class="line number235 index234 alt2">"csharp spaces"> "csharp plain">DAL.DeviceinfoDataSetTableAdapters.P_SELENABLEBYNUMBERTableAdapter da = "csharp keyword">new "csharp plain">DAL.DeviceinfoDataSetTableAdapters.P_SELENABLEBYNUMBERTableAdapter(); </div> <div class="line number236 index235 alt1">"csharp spaces"> "csharp plain">da.P_UPDSTATEBYTIME(_spandate); </div> <div class="line number237 index236 alt2">"csharp spaces"> "csharp plain">} </div> <div class="line number238 index237 alt1">"csharp spaces"> "csharp keyword">catch "csharp plain">(Exception ex) </div> <div class="line number239 index238 alt2">"csharp spaces"> "csharp plain">{ </div> <div class="line number240 index239 alt1">"csharp spaces"> "csharp plain">DAL.Log.Write(DateTime.Now + "csharp string">"\0" "csharp plain">+ ex + "csharp string">"\0\t\n""csharp plain">); </div> <div class="line number241 index240 alt2">"csharp spaces"> "csharp plain">} </div> <div class="line number242 index241 alt1">"csharp spaces"> "csharp plain">} </div> <div class="line number243 index242 alt2">"csharp spaces"> </div> <div class="line number244 index243 alt1">"csharp spaces"> "csharp preprocessor">#endregion </div> <div class="line number245 index244 alt2">"csharp spaces"> "csharp plain">} </div> <div class="line number246 index245 alt1">"csharp plain">}</div> </div> </div>
试试其它关键字
lelese7en
同语言下
.
文件IO 操作类库
.
Check图片类型[JPEG(.jpg 、.jpeg),TIF,GIF,BMP,PNG,P
.
机器名和IP取得(IPV4 IPV6)
.
Tiff转换Bitmap
.
linqHelper
.
MadieHelper.cs
.
RegHelper.cs
.
如果关闭一个窗体后激活另一个窗体的事件或方法
.
创建日志通用类
.
串口辅助开发类
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
Dezai.CN
贡献的其它代码
(
4037
)
.
多线程Socket服务器模块
.
生成随机密码
.
清除浮动样式
.
弹出窗口居中
.
抓取url的函数
.
使用base HTTP验证
.
div模拟iframe嵌入效果
.
通过header转向的方法
.
Session操作类
.
执行sqlite输入插入操作后获得自动编号的ID
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3